Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

infra: fix ruff configuration and add a few checks #573

Merged
merged 1 commit into from
Feb 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ repos:
rev: v0.12.1
hooks:
- id: validate-pyproject
- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
hooks:
- id: pyupgrade
args: ["--py37-plus"]
- repo: https://github.com/psf/black
rev: 22.12.0
hooks:
Expand All @@ -34,7 +29,7 @@ repos:
rev: 1.13.0
hooks:
- id: blacken-docs
additional_dependencies: [black==22.6]
additional_dependencies: [black==22.12]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.0.0-alpha.4"
hooks:
Expand All @@ -44,7 +39,7 @@ repos:
hooks:
- id: isort
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.237
rev: v0.0.238
hooks:
- id: ruff
args: [--fix, --format, grouped]
Expand All @@ -56,11 +51,6 @@ repos:
- repo: https://github.com/pre-commit/pygrep-hooks
rev: "v1.10.0"
hooks:
- id: python-check-blanket-noqa
- id: python-check-blanket-type-ignore
- id: python-no-log-warn
- id: python-no-eval
- id: python-use-type-annotations
- id: rst-backticks
- id: rst-directive-colons
- id: rst-inline-touching-normal
10 changes: 8 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,22 @@ skip = [] # "build" is included in the default skip list

[tool.ruff]
line-length = 127
target-version = "py37"
exclude = []
select = [
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"C9", # mccabe
"E", # pycodestyle
"F", # pyflakes
"PGH", # pygrep-hooks
"RUF", # ruff
"UP", # pyupgrade
"W", # pycodestyle
"W", # pycodestyle
"RUF100", # ruff
"YTT", # flake8-2020
]
src = ["src"]
target-version = "py37"

[tool.ruff.mccabe]
max-complexity = 10
2 changes: 1 addition & 1 deletion src/build/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ def build_package_via_sdist(
built.append(os.path.basename(out))
finally:
shutil.rmtree(sdist_out, ignore_errors=True)
return [sdist_name] + built
return [sdist_name, *built]


def main_parser() -> argparse.ArgumentParser:
Expand Down
6 changes: 3 additions & 3 deletions src/build/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ def check_dependency(
dist = importlib_metadata.distribution(req.name) # type: ignore[no-untyped-call]
except importlib_metadata.PackageNotFoundError:
# dependency is not installed in the environment.
yield ancestral_req_strings + (normalised_req_string,)
yield (*ancestral_req_strings, normalised_req_string)
else:
if req.specifier and not req.specifier.contains(dist.version, prereleases=True):
# the installed version is incompatible.
yield ancestral_req_strings + (normalised_req_string,)
yield (*ancestral_req_strings, normalised_req_string)
elif dist.requires:
for other_req_string in dist.requires:
# yields transitive dependencies that are not satisfied.
yield from check_dependency(other_req_string, ancestral_req_strings + (normalised_req_string,), req.extras)
yield from check_dependency(other_req_string, (*ancestral_req_strings, normalised_req_string), req.extras)


def parse_wheel_filename(filename: str) -> re.Match[str] | None:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def test_build(monkeypatch, project, args, call, tmp_path):
pytest.skip('Running via PYTHONPATH, so the pyproject-build entrypoint is not available')
path = get_project(project, tmp_path)
pkgs = tmp_path / 'pkgs'
args = [str(path), '-o', str(pkgs)] + args
args = [str(path), '-o', str(pkgs), *args]

if call is None:
build.__main__.main(args)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ def test_build_package_via_sdist_invalid_distribution(tmp_dir, package_test_setu
)
@pytest.mark.flaky(reruns=5)
def test_output(package_test_setuptools, tmp_dir, capsys, args, output):
build.__main__.main([package_test_setuptools, '-o', tmp_dir] + args)
build.__main__.main([package_test_setuptools, '-o', tmp_dir, *args])
stdout, stderr = capsys.readouterr()
assert stdout.splitlines() == output

Expand Down