diff options
| author | alevitskii <[email protected]> | 2025-09-04 10:00:21 +0300 |
|---|---|---|
| committer | alevitskii <[email protected]> | 2025-09-04 10:19:32 +0300 |
| commit | 8da3e97c84353501738d1ff485708bf8b7185eb8 (patch) | |
| tree | dfe1363035f5daa04064c8cdacc3835b3a5cdf90 /library/python/testing/style | |
| parent | 4c3f3af78aac956c2d034edb4a0d7c778b9fe9d3 (diff) | |
DEPENDS on linter wrappers to get them exported to opensource
DEPENDS on linter wrappers to get them exported to oss
commit_hash:286fa6981744f667a509749a33afcc3421903842
Diffstat (limited to 'library/python/testing/style')
| -rw-r--r-- | library/python/testing/style/rules.py | 42 | ||||
| -rw-r--r-- | library/python/testing/style/ya.make | 11 |
2 files changed, 53 insertions, 0 deletions
diff --git a/library/python/testing/style/rules.py b/library/python/testing/style/rules.py new file mode 100644 index 00000000000..dde87a45b3b --- /dev/null +++ b/library/python/testing/style/rules.py @@ -0,0 +1,42 @@ +# XXX: This module is used in linter tools in `tools/` which are run by test_tool. +# test_tool and `tools/` have different release cycles. Beware when modifying. +import os +import six + + +def style_required(path, data, skip_links=True): + if get_skip_reason(path, data, skip_links): + return False + return True + + +def get_skip_reason(path, data, skip_links=True): + return _path_skip_reason(path, skip_links) or _content_skip_reason(path, data) + + +def _path_skip_reason(path, skip_links=True): + if '/generated/' in path: + return "path '{}' contains '/generated/'".format(path) + + if path and '/contrib/' in path and '/.yandex_meta/' not in path: + return "path '{}' contains '/contrib/'".format(path) + + if path and '/vendor/' in path: + return "path '{}' contains '/vendor/'".format(path) + + if skip_links and os.path.islink(path): + return "path '{}' is a symlink".format(path) + + +def _content_skip_reason(path, data): + if not isinstance(data, six.string_types): + data = data.decode() + + for substr in [ + '# DO_NOT_STYLE', + '// DO_NOT_STYLE', + 'THIS SOFTWARE', + 'WITHOUT WARRANT', # WARRANTY, WARRANTIES + ]: + if substr in data: + return "file '{}' contains '{}'".format(path, substr) diff --git a/library/python/testing/style/ya.make b/library/python/testing/style/ya.make new file mode 100644 index 00000000000..7d3e9efd6b0 --- /dev/null +++ b/library/python/testing/style/ya.make @@ -0,0 +1,11 @@ +PY23_LIBRARY() + +PY_SRCS( + rules.py +) + +PEERDIR( + contrib/python/six +) + +END() |
