From 7b4f021fa8c2a1e1329ae4bd23cded471df59d2d Mon Sep 17 00:00:00 2001 From: Jacob Floyd Date: Sat, 18 Jun 2022 16:35:17 -0500 Subject: [PATCH] use regex-lint to provide circular dependency checking in pants --- lint-configs/regex-lint.yaml | 101 +++++++++++++++++++++++++++++++++++ pants.toml | 3 ++ 2 files changed, 104 insertions(+) create mode 100644 lint-configs/regex-lint.yaml diff --git a/lint-configs/regex-lint.yaml b/lint-configs/regex-lint.yaml new file mode 100644 index 0000000000..624d2abbd0 --- /dev/null +++ b/lint-configs/regex-lint.yaml @@ -0,0 +1,101 @@ +# Note that for values that are regexes, how YAML interprets backslashes and other +# special characters matters. For example, an unquoted string is interpreted as a raw +# string with no escape characters (so it's particularly useful for expressing regexes). +# Adding quotes around these may change their meaning, so don't do so without thought. + +required_matches: + # If we decide to enable this, remove the st2flake8 + #python_source: + # - python_header + #build_files: + # - python_header + + # TODO: In the future pants should get `visibility` and possibly other + # features to restrict imports for dependees or dependencies. + # - https://github.com/pantsbuild/pants/issues/13393 + # - https://github.com/pantsbuild/pants/pull/15803 + # - https://github.com/pantsbuild/pants/pull/15836 + # When that happens, we can add that target metadata, + # and remove these regex based dependency checks. + + # st2client-dependencies-check + st2client: + - must_not_import_st2common + + # st2common-circular-dependencies-check + st2common: + - must_not_import_st2reactor + - must_not_import_st2api + - must_not_import_st2auth + #- must_not_import_st2actions + #- must_not_import_st2stream + st2common_except_services_inquiry: + # The makefile excluded: runnersregistrar.py, compat.py, inquiry.py + # runnersregistrar does not have an st2actions ref since 2016. + # compat.py st2actions function was added and removed in 2017. + # services/inquiry.py still imports st2actions. + - must_not_import_st2actions + st2common_except_router: + # The makefile excluded router.py from st2stream check. + # In router.py, "st2stream" is a string, not an import. + - must_not_import_st2stream + +path_patterns: + #- name: python_source + # pattern: (?