aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorprettyboy <prettyboy@yandex-team.com>2023-09-22 01:24:48 +0300
committerprettyboy <prettyboy@yandex-team.com>2023-09-22 01:53:30 +0300
commit2848d0b609b460524bfefbdad19508dc120de001 (patch)
treebe27b646e48474b6f449426fbdbcc14f05104fdf
parent275bbb28224e7dae22959f79299b7ee348098f89 (diff)
downloadydb-2848d0b609b460524bfefbdad19508dc120de001.tar.gz
[library/python] Fix some style tests
см https://a.yandex-team.ru/review/4511498/details?checkId=29700000007055&dialogId=CiCard&filter=resultType%28RT_STYLE_CHECK%29%3BsuiteCategory%28CATEGORY_CHANGED%29&iterationType=FULL&number=1&openedItems=955241967903872625%3ART_STYLE_SUITE_CHECK%2C12143061788616128922%3ART_STYLE_SUITE_CHECK%2C8023375544570871616%3ART_STYLE_SUITE_CHECK%2C10700057700434354061%3ART_STYLE_SUITE_CHECK%2C10919096887128703016%3ART_STYLE_SUITE_CHECK%2C8720280302786645361%3ART_STYLE_SUITE_CHECK%2C16643406941049220442%3ART_STYLE_SUITE_CHECK%2C12501056625690179524%3ART_STYLE_SUITE_CHECK&snippetViewMode=word-wrap&status=STATUS_FAILED
-rw-r--r--library/python/cpp_test/conftest.py16
-rw-r--r--library/python/cyson/cyson/__init__.py2
-rw-r--r--library/python/pytest/plugins/conftests.py1
-rw-r--r--library/python/pytest/plugins/metrics.py4
-rw-r--r--library/python/pytest/plugins/ya.py9
-rw-r--r--library/python/pytest/rewrite.py2
-rw-r--r--library/python/resource/__init__.py8
-rw-r--r--library/python/testing/yatest_common/yatest/common/canonical.py6
-rw-r--r--library/python/testing/yatest_common/yatest/common/process.py5
9 files changed, 33 insertions, 20 deletions
diff --git a/library/python/cpp_test/conftest.py b/library/python/cpp_test/conftest.py
index 40576c3aac..5e9a0fbf9a 100644
--- a/library/python/cpp_test/conftest.py
+++ b/library/python/cpp_test/conftest.py
@@ -2,16 +2,16 @@ import difflib
def iter_diff(fr, to):
- for l in difflib.unified_diff(fr.splitlines(), to.splitlines(), fromfile='L', tofile='R'):
- l = l.rstrip('\n')
+ for line in difflib.unified_diff(fr.splitlines(), to.splitlines(), fromfile='L', tofile='R'):
+ line = line.rstrip('\n')
- if l:
- if l[0] == '-':
- l = '[[bad]]' + l + '[[rst]]'
- elif l[0] == '+':
- l = '[[good]]' + l + '[[rst]]'
+ if line:
+ if line[0] == '-':
+ line = '[[bad]]' + line + '[[rst]]'
+ elif line[0] == '+':
+ line = '[[good]]' + line + '[[rst]]'
- yield l
+ yield line
def pytest_assertrepr_compare(op, left, right):
diff --git a/library/python/cyson/cyson/__init__.py b/library/python/cyson/cyson/__init__.py
index 5e0cac2241..a10a9d810f 100644
--- a/library/python/cyson/cyson/__init__.py
+++ b/library/python/cyson/cyson/__init__.py
@@ -14,4 +14,4 @@ __all__ = [
'YsonEntity', 'YsonString', 'YsonInt64', 'YsonUInt64',
'YsonFloat64', 'YsonBoolean', 'YsonList', 'YsonMap',
'UInt', 'UnicodeReader',
-]
+] # noqa: F405
diff --git a/library/python/pytest/plugins/conftests.py b/library/python/pytest/plugins/conftests.py
index 37062bda06..3224d2c84f 100644
--- a/library/python/pytest/plugins/conftests.py
+++ b/library/python/pytest/plugins/conftests.py
@@ -20,6 +20,7 @@ def getfile(object):
res = orig_getfile(object)
return res
+
inspect.getfile = getfile
conftest_modules = []
diff --git a/library/python/pytest/plugins/metrics.py b/library/python/pytest/plugins/metrics.py
index b6431c8b8e..e0e5a94982 100644
--- a/library/python/pytest/plugins/metrics.py
+++ b/library/python/pytest/plugins/metrics.py
@@ -1,10 +1,14 @@
class TestMetrics:
metrics = {}
+
def __getitem__(self, key):
return self.metrics.__getitem__(key)
+
def __setitem__(self, key, value):
return self.metrics.__setitem__(key, value)
+
def get(self, key):
return self.metrics.get(key)
+
test_metrics = TestMetrics()
diff --git a/library/python/pytest/plugins/ya.py b/library/python/pytest/plugins/ya.py
index def3534d76..a02ef6852e 100644
--- a/library/python/pytest/plugins/ya.py
+++ b/library/python/pytest/plugins/ya.py
@@ -2,7 +2,6 @@
import base64
import errno
-import re
import sys
import os
import logging
@@ -15,7 +14,6 @@ import signal
import inspect
import warnings
-import attr
import faulthandler
import py
import pytest
@@ -68,6 +66,7 @@ SHUTDOWN_REQUESTED = False
pytest_config = None
+
def configure_pdb_on_demand():
import signal
@@ -185,6 +184,7 @@ def pytest_addoption(parser):
def from_ya_test():
return "YA_TEST_RUNNER" in os.environ
+
@pytest.hookimpl(tryfirst=True)
def pytest_configure(config):
global pytest_config
@@ -344,8 +344,11 @@ def _collect_test_rusage(item):
def add_metric(attr_name, metric_name=None, modifier=None):
if not metric_name:
metric_name = attr_name
+
if not modifier:
- modifier = lambda x: x
+ def modifier(x):
+ return x
+
if hasattr(item.rusage, attr_name):
ya_inst.set_metric_value(metric_name, modifier(getattr(finish_rusage, attr_name) - getattr(item.rusage, attr_name)))
diff --git a/library/python/pytest/rewrite.py b/library/python/pytest/rewrite.py
index 38e80ebf5d..4ca44e1fb3 100644
--- a/library/python/pytest/rewrite.py
+++ b/library/python/pytest/rewrite.py
@@ -93,7 +93,7 @@ class AssertionRewritingHook(rewrite.AssertionRewritingHook):
module.__cached__ = None
module.__loader__ = self
module.__spec__ = importlib.util.spec_from_file_location(module.__name__, co.co_filename, loader=self)
- exec(co, module.__dict__)
+ exec(co, module.__dict__) # noqa
except: # noqa
if module.__name__ in sys.modules:
del sys.modules[module.__name__]
diff --git a/library/python/resource/__init__.py b/library/python/resource/__init__.py
index 751186b200..366fdb8d70 100644
--- a/library/python/resource/__init__.py
+++ b/library/python/resource/__init__.py
@@ -5,10 +5,10 @@ import six
def iterkeys(prefix="", strip_prefix=False):
- decode = lambda s: s
+ decode = lambda s: s # noqa: E731
if isinstance(prefix, six.text_type):
prefix = prefix.encode("utf-8")
- decode = lambda s: s.decode("utf-8")
+ decode = lambda s: s.decode("utf-8") # noqa: E731
for i in six.moves.range(count()):
key = key_by_index(i)
@@ -37,9 +37,9 @@ def resfs_file_exists(path):
def resfs_files(prefix=""):
- decode = lambda s: s
+ decode = lambda s: s # noqa: E731
if isinstance(prefix, six.text_type):
- decode = lambda s: s.decode("utf-8")
+ decode = lambda s: s.decode("utf-8") # noqa: E731
return [decode(s) for s in __resfs_files(prefix=prefix)]
diff --git a/library/python/testing/yatest_common/yatest/common/canonical.py b/library/python/testing/yatest_common/yatest/common/canonical.py
index 0bce0fde7a..c964b076cc 100644
--- a/library/python/testing/yatest_common/yatest/common/canonical.py
+++ b/library/python/testing/yatest_common/yatest/common/canonical.py
@@ -46,7 +46,7 @@ def canonical_file(
try: # check if iterable
if not isinstance(diff_tool[0], six.string_types):
raise Exception("Invalid custom diff-tool: not cmd")
- except:
+ except Exception:
raise Exception("Invalid custom diff-tool: not binary path")
return runtime._get_ya_plugin_instance().file(
safe_path, diff_tool=diff_tool, local=local, diff_file_name=diff_file_name, diff_tool_timeout=diff_tool_timeout
@@ -217,7 +217,9 @@ def _canonical_execute(
out_file_path = path.get_unique_file_path(runtime.output_path(), "{}.out.txt".format(file_name))
err_file_path = path.get_unique_file_path(runtime.output_path(), "{}.err.txt".format(file_name))
if not data_transformer:
- data_transformer = lambda x: x
+
+ def data_transformer(x):
+ return x
try:
os.makedirs(os.path.dirname(out_file_path))
diff --git a/library/python/testing/yatest_common/yatest/common/process.py b/library/python/testing/yatest_common/yatest/common/process.py
index c6c8aed526..69988be84c 100644
--- a/library/python/testing/yatest_common/yatest/common/process.py
+++ b/library/python/testing/yatest_common/yatest/common/process.py
@@ -373,7 +373,10 @@ class _Execution(object):
try:
if timeout:
- process_is_finished = lambda: not self.running
+
+ def process_is_finished():
+ return not self.running
+
fail_message = "Command '%s' stopped by %d seconds timeout" % (self._command, timeout)
try:
wait_for(