Commit 85b29df0 by Daniel Eades Committed by Arun Babu Neelicattu

use flake8-bugbear for linting

parent ee67aa8c
...@@ -8,6 +8,7 @@ repos: ...@@ -8,6 +8,7 @@ repos:
rev: 3.8.4 rev: 3.8.4
hooks: hooks:
- id: flake8 - id: flake8
additional_dependencies: [flake8-bugbear]
- repo: https://github.com/timothycrosley/isort - repo: https://github.com/timothycrosley/isort
rev: 5.7.0 rev: 5.7.0
......
...@@ -52,7 +52,7 @@ class CacheClearCommand(Command): ...@@ -52,7 +52,7 @@ class CacheClearCommand(Command):
# Calculate number of entries # Calculate number of entries
entries_count = 0 entries_count = 0
for path, dirs, files in os.walk(str(cache_dir)): for _path, _dirs, files in os.walk(str(cache_dir)):
entries_count += len(files) entries_count += len(files)
delete = self.confirm( delete = self.confirm(
......
...@@ -618,8 +618,8 @@ class Provider: ...@@ -618,8 +618,8 @@ class Provider:
# - {<Package foo (1.2.3): {"bar": <Dependency bar (>=2.0)>} # - {<Package foo (1.2.3): {"bar": <Dependency bar (>=2.0)>}
# - {<Package foo (1.2.3): {"bar": <Dependency bar (<2.0)>} # - {<Package foo (1.2.3): {"bar": <Dependency bar (<2.0)>}
markers = [] markers = []
for constraint, _deps in by_constraint.items(): for deps in by_constraint.values():
markers.append(_deps[0].marker) markers.append(deps[0].marker)
_deps = [_dep[0] for _dep in by_constraint.values()] _deps = [_dep[0] for _dep in by_constraint.values()]
self.debug( self.debug(
......
...@@ -138,7 +138,7 @@ class Pool(BaseRepository): ...@@ -138,7 +138,7 @@ class Pool(BaseRepository):
except PackageNotFound: except PackageNotFound:
pass pass
else: else:
for idx, repo in enumerate(self._repositories): for repo in self._repositories:
try: try:
package = repo.package(name, version, extras=extras) package = repo.package(name, version, extras=extras)
except PackageNotFound: except PackageNotFound:
......
...@@ -1487,8 +1487,8 @@ class SystemEnv(Env): ...@@ -1487,8 +1487,8 @@ class SystemEnv(Env):
paths[key] = getattr(obj, f"install_{key}") paths[key] = getattr(obj, f"install_{key}")
if site.check_enableusersite() and hasattr(obj, "install_usersite"): if site.check_enableusersite() and hasattr(obj, "install_usersite"):
paths["usersite"] = getattr(obj, "install_usersite") paths["usersite"] = obj.install_usersite
paths["userbase"] = getattr(obj, "install_userbase") paths["userbase"] = obj.install_userbase
return paths return paths
......
...@@ -82,7 +82,7 @@ def safe_rmtree(path: str) -> None: ...@@ -82,7 +82,7 @@ def safe_rmtree(path: str) -> None:
def merge_dicts(d1: Dict, d2: Dict) -> None: def merge_dicts(d1: Dict, d2: Dict) -> None:
for k, v in d2.items(): for k in d2.keys():
if k in d1 and isinstance(d1[k], dict) and isinstance(d2[k], Mapping): if k in d1 and isinstance(d1[k], dict) and isinstance(d2[k], Mapping):
merge_dicts(d1[k], d2[k]) merge_dicts(d1[k], d2[k])
else: else:
......
...@@ -159,7 +159,7 @@ class MakeReleaseCommand(Command): ...@@ -159,7 +159,7 @@ class MakeReleaseCommand(Command):
fileobj=gz, fileobj=gz,
format=tarfile.PAX_FORMAT, format=tarfile.PAX_FORMAT,
) as tar: ) as tar:
for root, dirs, files in os.walk(tmp_dir): for root, _dirs, files in os.walk(tmp_dir):
for f in files: for f in files:
if f.endswith(".pyc"): if f.endswith(".pyc"):
continue continue
......
...@@ -5,11 +5,14 @@ from typing import Union ...@@ -5,11 +5,14 @@ from typing import Union
from poetry.core.semver.version import Version from poetry.core.semver.version import Version
def build_venv(path: Union[Path, str], **_: Any) -> (): VERSION_3_7_1 = Version.parse("3.7.1")
def build_venv(path: Union[Path, str], **_: Any) -> None:
Path(path).mkdir(parents=True, exist_ok=True) Path(path).mkdir(parents=True, exist_ok=True)
def check_output_wrapper(version=Version.parse("3.7.1")): def check_output_wrapper(version=VERSION_3_7_1):
def check_output(cmd, *_, **__): def check_output(cmd, *_, **__):
if "sys.version_info[:3]" in cmd: if "sys.version_info[:3]" in cmd:
return version.text return version.text
......
...@@ -191,7 +191,7 @@ def test_pypi_repository_supports_reading_bz2_files(): ...@@ -191,7 +191,7 @@ def test_pypi_repository_supports_reading_bz2_files():
] ]
} }
for name, deps in expected_extras.items(): for name in expected_extras.keys():
assert expected_extras[name] == sorted( assert expected_extras[name] == sorted(
package.extras[name], key=lambda r: r.name package.extras[name], key=lambda r: r.name
) )
......
...@@ -120,11 +120,14 @@ def test_env_get_venv_with_venv_folder_present( ...@@ -120,11 +120,14 @@ def test_env_get_venv_with_venv_folder_present(
assert venv.path == in_project_venv_dir assert venv.path == in_project_venv_dir
def build_venv(path: Union[Path, str], **__: Any) -> (): def build_venv(path: Union[Path, str], **__: Any) -> None:
os.mkdir(str(path)) os.mkdir(str(path))
def check_output_wrapper(version=Version.parse("3.7.1")): VERSION_3_7_1 = Version.parse("3.7.1")
def check_output_wrapper(version=VERSION_3_7_1):
def check_output(cmd, *args, **kwargs): def check_output(cmd, *args, **kwargs):
if "sys.version_info[:3]" in cmd: if "sys.version_info[:3]" in cmd:
return version.text return version.text
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment