From db2039fe2f333bc33342b4168910b7ed0a626bbd Mon Sep 17 00:00:00 2001 From: Benjamin Schubert Date: Thu, 7 May 2020 22:06:03 +0100 Subject: lint: Stop using mutable objects for default arguments --- src/buildstream/_gitsourcebase.py | 4 ++-- src/buildstream/_includes.py | 9 ++++++--- src/buildstream/testing/_utils/junction.py | 2 +- tests/testutils/junction.py | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/buildstream/_gitsourcebase.py b/src/buildstream/_gitsourcebase.py index 1f74bb972..e3b246677 100644 --- a/src/buildstream/_gitsourcebase.py +++ b/src/buildstream/_gitsourcebase.py @@ -70,14 +70,14 @@ def _strip_tag(rev): # tags (list): Tag configuration; see _GitSourceBase._load_tags # class _GitMirror(SourceFetcher): - def __init__(self, source, path, url, ref, *, primary=False, tags=[]): + def __init__(self, source, path, url, ref, *, primary=False, tags=None): super().__init__() self.source = source self.path = path self.url = url self.ref = ref - self.tags = tags + self.tags = tags or [] self.primary = primary self.mirror = os.path.join(source.get_mirror_directory(), utils.url_directory_name(url)) diff --git a/src/buildstream/_includes.py b/src/buildstream/_includes.py index b9a1c0d22..2ecb70a31 100644 --- a/src/buildstream/_includes.py +++ b/src/buildstream/_includes.py @@ -42,7 +42,7 @@ class Includes: # current_loader (Loader): Use alternative loader (for junction files) # only_local (bool): Whether to ignore junction files # process_project_options (bool): Whether to process options from current project - def _process(self, node, *, included=set(), current_loader=None, only_local=False, process_project_options=True): + def _process(self, node, *, included=None, current_loader=None, only_local=False, process_project_options=True): if current_loader is None: current_loader = self._loader @@ -69,8 +69,11 @@ class Includes: # only_local (bool): Whether to ignore junction files # process_project_options (bool): Whether to process options from current project def _process_node( - self, node, *, included=set(), current_loader=None, only_local=False, process_project_options=True + self, node, *, included=None, current_loader=None, only_local=False, process_project_options=True ): + if included is None: + included = set() + includes_node = node.get_node("(@)", allowed_types=[ScalarNode, SequenceNode], allow_none=True) if includes_node: @@ -172,7 +175,7 @@ class Includes: # only_local (bool): Whether to ignore junction files # process_project_options (bool): Whether to process options from current project def _process_value( - self, value, *, included=set(), current_loader=None, only_local=False, process_project_options=True + self, value, *, included=None, current_loader=None, only_local=False, process_project_options=True ): value_type = type(value) diff --git a/src/buildstream/testing/_utils/junction.py b/src/buildstream/testing/_utils/junction.py index 6f45ad590..8f80ed6bd 100644 --- a/src/buildstream/testing/_utils/junction.py +++ b/src/buildstream/testing/_utils/junction.py @@ -19,7 +19,7 @@ from .site import HAVE_GIT, GIT, GIT_ENV # Returns: # (str): The ref # -def generate_junction(tmpdir, subproject_path, junction_path, *, store_ref=True, options={}): +def generate_junction(tmpdir, subproject_path, junction_path, *, store_ref=True, options=None): # Create a repo to hold the subproject and generate # a junction element for it # diff --git a/tests/testutils/junction.py b/tests/testutils/junction.py index 99117b2cf..4889fdb24 100644 --- a/tests/testutils/junction.py +++ b/tests/testutils/junction.py @@ -15,7 +15,7 @@ from buildstream.testing import create_repo # Returns: # (str): The ref # -def generate_junction(tmpdir, subproject_path, junction_path, *, store_ref=True, options={}): +def generate_junction(tmpdir, subproject_path, junction_path, *, store_ref=True, options=None): # Create a repo to hold the subproject and generate # a junction element for it # -- cgit v1.2.1 From f5e8a54f095f28870d4c483ca56cc1abc01a2229 Mon Sep 17 00:00:00 2001 From: Benjamin Schubert Date: Fri, 20 Mar 2020 16:19:52 +0000 Subject: Update all packages requirements Also fix linting errors coming with new version of pylint --- requirements/cov-requirements.in | 1 + requirements/cov-requirements.txt | 20 ++++++++-------- requirements/dev-requirements.in | 4 +++- requirements/dev-requirements.txt | 37 ++++++++++++++++-------------- requirements/requirements.txt | 20 ++++++++-------- src/buildstream/_cas/casdprocessmanager.py | 2 +- src/buildstream/source.py | 2 +- src/buildstream/types.py | 2 +- tests/frontend/artifact_list_contents.py | 2 +- tests/frontend/init.py | 2 +- tests/frontend/logging.py | 4 +--- tests/integration/shell.py | 2 +- tox.ini | 2 +- 13 files changed, 52 insertions(+), 48 deletions(-) diff --git a/requirements/cov-requirements.in b/requirements/cov-requirements.in index fb582f816..5acb5cec5 100644 --- a/requirements/cov-requirements.in +++ b/requirements/cov-requirements.in @@ -1,3 +1,4 @@ coverage == 4.4.0 pytest-cov >= 2.5.0 +pytest >= 3.9,!= 5.4.0,!= 5.4.1 Cython diff --git a/requirements/cov-requirements.txt b/requirements/cov-requirements.txt index c700ababf..2934d29ef 100644 --- a/requirements/cov-requirements.txt +++ b/requirements/cov-requirements.txt @@ -1,15 +1,15 @@ coverage==4.4 pytest-cov==2.8.1 -Cython==0.29.14 +pytest==5.4.2 +Cython==0.29.17 ## The following requirements were added by pip freeze: attrs==19.3.0 -importlib-metadata==1.1.0 -more-itertools==8.0.0 -packaging==19.2 +importlib-metadata==1.6.0 +more-itertools==8.2.0 +packaging==20.3 pluggy==0.13.1 -py==1.8.0 -pyparsing==2.4.5 -pytest==5.3.1 -six==1.13.0 -wcwidth==0.1.7 -zipp==0.6.0 +py==1.8.1 +pyparsing==2.4.7 +six==1.14.0 +wcwidth==0.1.9 +zipp==3.1.0 diff --git a/requirements/dev-requirements.in b/requirements/dev-requirements.in index 220ec574e..bba068428 100644 --- a/requirements/dev-requirements.in +++ b/requirements/dev-requirements.in @@ -1,6 +1,8 @@ pexpect pylint -pytest >= 3.9 +# Pytest 5.4.0 and 5.4.1 have a bug with --basetemp and xdist +# We should not install those +pytest >= 3.9,!= 5.4.0,!= 5.4.1 pytest-datafiles >= 2.0 pytest-env pytest-xdist diff --git a/requirements/dev-requirements.txt b/requirements/dev-requirements.txt index 15e9b30a6..5a8ab1863 100644 --- a/requirements/dev-requirements.txt +++ b/requirements/dev-requirements.txt @@ -1,29 +1,32 @@ -pexpect==4.7.0 -pylint==2.4.4 -pytest==5.3.1 +pexpect==4.8.0 +pylint==2.5.2 +# Pytest 5.4.0 and 5.4.1 have a bug with --basetemp and xdist +# We should not install those +pytest==5.4.2 pytest-datafiles==2.0 pytest-env==0.6.2 -pytest-xdist==1.30.0 -pytest-timeout==1.3.3 -pyftpdlib==1.5.5 +pytest-xdist==1.32.0 +pytest-timeout==1.3.4 +pyftpdlib==1.5.6 ## The following requirements were added by pip freeze: apipkg==1.5 -astroid==2.3.3 +astroid==2.4.1 attrs==19.3.0 execnet==1.7.1 -importlib-metadata==1.1.0 +importlib-metadata==1.6.0 isort==4.3.21 lazy-object-proxy==1.4.3 mccabe==0.6.1 -more-itertools==8.0.0 -packaging==19.2 +more-itertools==8.2.0 +packaging==20.3 pluggy==0.13.1 ptyprocess==0.6.0 -py==1.8.0 -pyparsing==2.4.5 +py==1.8.1 +pyparsing==2.4.7 pytest-forked==1.1.3 -six==1.13.0 -typed-ast==1.4.0 -wcwidth==0.1.7 -wrapt==1.11.2 -zipp==0.6.0 +six==1.14.0 +toml==0.10.0 +typed-ast==1.4.1 +wcwidth==0.1.9 +wrapt==1.12.1 +zipp==3.1.0 diff --git a/requirements/requirements.txt b/requirements/requirements.txt index ab7a3a1f7..39759fc49 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -1,15 +1,15 @@ -Click==7.0 -grpcio==1.25.0 -Jinja2==2.10.3 +grpcio==1.28.1 +Jinja2==2.11.2 pluginbase==1.0.0 -protobuf==3.11.0 -psutil==5.6.7 -ruamel.yaml==0.16.5 -setuptools==39.0.1 +protobuf==3.11.3 +psutil==5.7.0 +ruamel.yaml==0.16.10 +ruamel.yaml.clib==0.2.0 +setuptools==41.6.0 pyroaring==0.2.9 -ujson==1.35 +ujson==2.0.3 python-dateutil==2.8.1 ## The following requirements were added by pip freeze: +click==7.1.2 MarkupSafe==1.1.1 -ruamel.yaml.clib==0.2.0 -six==1.13.0 +six==1.14.0 diff --git a/src/buildstream/_cas/casdprocessmanager.py b/src/buildstream/_cas/casdprocessmanager.py index 5ba192d1e..9536d9f8d 100644 --- a/src/buildstream/_cas/casdprocessmanager.py +++ b/src/buildstream/_cas/casdprocessmanager.py @@ -251,7 +251,7 @@ class CASDChannel: try: proc = psutil.Process(self._casd_pid) if not proc.is_running(): - raise CASCacheError(f"buildbox-casd process died before connection could be established") + raise CASCacheError("buildbox-casd process died before connection could be established") except psutil.NoSuchProcess: raise CASCacheError("buildbox-casd process died before connection could be established") diff --git a/src/buildstream/source.py b/src/buildstream/source.py index c0744e8e7..7b790cdbb 100644 --- a/src/buildstream/source.py +++ b/src/buildstream/source.py @@ -765,7 +765,7 @@ class Source(Plugin): # SourceErrors should be preserved so that the # plugin can communicate real error cases. raise - except Exception as err: # pylint: broad-except + except Exception as err: # Generic errors point to bugs in the plugin, so # we need to catch them and make sure they do not # cause stacktraces diff --git a/src/buildstream/types.py b/src/buildstream/types.py index 4d7a4c650..3d97fc7b9 100644 --- a/src/buildstream/types.py +++ b/src/buildstream/types.py @@ -223,7 +223,7 @@ class _PipelineSelection(FastEnum): RUN = "run" def __str__(self): - return self.value + return str(self.value) ######################################## diff --git a/tests/frontend/artifact_list_contents.py b/tests/frontend/artifact_list_contents.py index a1473c806..8bd7bdeff 100644 --- a/tests/frontend/artifact_list_contents.py +++ b/tests/frontend/artifact_list_contents.py @@ -39,7 +39,7 @@ def test_artifact_list_exact_contents_element(cli, datafiles): # List the contents via the element name result = cli.run(project=project, args=["artifact", "list-contents", "import-bin.bst"]) assert result.exit_code == 0 - expected_output = "import-bin.bst:\n" "\tusr\n" "\tusr/bin\n" "\tusr/bin/hello\n\n" + expected_output = "import-bin.bst:\n\tusr\n\tusr/bin\n\tusr/bin/hello\n\n" assert expected_output in result.output diff --git a/tests/frontend/init.py b/tests/frontend/init.py index db1b9c955..3f897fb14 100644 --- a/tests/frontend/init.py +++ b/tests/frontend/init.py @@ -138,7 +138,7 @@ def test_element_path_interactive(cli, tmp_path, monkeypatch, element_path): def create(cls, *args, **kwargs): return DummyInteractiveApp(*args, **kwargs) - def _init_project_interactive(self, *args, **kwargs): # pylint: disable=arguments-differ + def _init_project_interactive(self, *args, **kwargs): # pylint: disable=signature-differs return ("project_name", "2.0", element_path) monkeypatch.setattr(App, "create", DummyInteractiveApp.create) diff --git a/tests/frontend/logging.py b/tests/frontend/logging.py index 7db37fa4c..6eb058990 100644 --- a/tests/frontend/logging.py +++ b/tests/frontend/logging.py @@ -48,9 +48,7 @@ def test_custom_logging(cli, tmpdir, datafiles): element_path = os.path.join(project, "elements") element_name = "fetch-test-git.bst" - custom_log_format = ( - "%{elapsed},%{elapsed-us},%{wallclock},%{wallclock-us}," "%{key},%{element},%{action},%{message}" - ) + custom_log_format = "%{elapsed},%{elapsed-us},%{wallclock},%{wallclock-us},%{key},%{element},%{action},%{message}" user_config = {"logging": {"message-format": custom_log_format}} cli.configure(user_config) diff --git a/tests/integration/shell.py b/tests/integration/shell.py index 11aba87da..42e486bac 100644 --- a/tests/integration/shell.py +++ b/tests/integration/shell.py @@ -331,7 +331,7 @@ def test_integration_external_workspace(cli, tmpdir_factory, datafiles, build_sh if guess_element: # Mutate the project.conf to use a default shell command project_file = os.path.join(project, "project.conf") - config_text = "shell:\n" " command: ['true']\n" + config_text = "shell:\n command: ['true']\n" with open(project_file, "a") as f: f.write(config_text) diff --git a/tox.ini b/tox.ini index 843571efe..5c082d6dd 100644 --- a/tox.ini +++ b/tox.ini @@ -147,7 +147,7 @@ commands_pre = {envpython} setup.py build_ext --inplace commands = - pylint {posargs: src tests doc/source/conf.py setup.py} + pylint {posargs: src/buildstream tests doc/source/conf.py setup.py} deps = -rrequirements/requirements.txt -rrequirements/dev-requirements.txt -- cgit v1.2.1