-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Ruff: lint pytest #4557
Ruff: lint pytest #4557
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ extend-select = [ | |
"I", # isort | ||
"PERF", # Perflint | ||
"PGH", # pygrep-hooks (blanket-* rules) | ||
"PT", # flake8-pytest-style | ||
"PYI", # flake8-pyi | ||
"RUF10", # unused-noqa & redirected-noqa | ||
"TRY", # tryceratops | ||
|
@@ -28,6 +29,11 @@ extend-select = [ | |
] | ||
ignore = [ | ||
"PERF203", # try-except-in-loop, micro-optimisation with many false-positive. Worth checking but don't block CI | ||
"PT004", # deprecated https://github.com/astral-sh/ruff/issues/8796#issuecomment-2057143531 | ||
"PT005", # deprecated https://github.com/astral-sh/ruff/issues/8796#issuecomment-2057143531 | ||
"PT007", # temporarily disabled, TODO: configure and standardize to preference | ||
"PT011", # temporarily disabled, TODO: tighten expected error | ||
"PT012", # pytest-raises-with-multiple-statements, avoid extra dummy methods for a few lines, sometimes we explicitly assert in case of no error | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I felt like the changes |
||
"TRY003", # raise-vanilla-args, avoid multitude of exception classes | ||
"TRY301", # raise-within-try, it's handy | ||
"UP015", # redundant-open-modes, explicit is preferred | ||
|
@@ -75,6 +81,9 @@ sections.delayed = ["distutils"] | |
[lint.flake8-annotations] | ||
ignore-fully-untyped = true | ||
|
||
[lint.flake8-pytest-style] | ||
parametrize-names-type = "csv" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I went with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should be OK to change to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It can autofix it, it's simply marked as an "unsafe fix". Happy to provide a follow-up PR or add it here (there's 41 hits) |
||
|
||
[format] | ||
# Enable preview to get hugged parenthesis unwrapping and other nice surprises | ||
# See https://github.com/jaraco/skeleton/pull/133#issuecomment-2239538373 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,23 +104,22 @@ def venv_python(tmp_path): | |
|
||
|
||
@pytest.fixture(autouse=True) | ||
def _prepare(tmp_path, venv_python, monkeypatch, request): | ||
def _prepare(tmp_path, venv_python, monkeypatch): | ||
download_path = os.getenv("DOWNLOAD_PATH", str(tmp_path)) | ||
os.makedirs(download_path, exist_ok=True) | ||
|
||
# Environment vars used for building some of the packages | ||
monkeypatch.setenv("USE_MYPYC", "1") | ||
|
||
def _debug_info(): | ||
# Let's provide the maximum amount of information possible in the case | ||
# it is necessary to debug the tests directly from the CI logs. | ||
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~") | ||
print("Temporary directory:") | ||
map(print, tmp_path.glob("*")) | ||
print("Virtual environment:") | ||
run([venv_python, "-m", "pip", "freeze"]) | ||
yield | ||
|
||
request.addfinalizer(_debug_info) | ||
# Let's provide the maximum amount of information possible in the case | ||
# it is necessary to debug the tests directly from the CI logs. | ||
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~") | ||
print("Temporary directory:") | ||
map(print, tmp_path.glob("*")) | ||
print("Virtual environment:") | ||
run([venv_python, "-m", "pip", "freeze"]) | ||
Comment on lines
+114
to
+122
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
|
||
@pytest.mark.parametrize('package, version', EXAMPLES) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,7 @@ | |
|
||
@pytest.fixture(autouse=True) | ||
def isolated_dir(tmpdir_cwd): | ||
yield | ||
return | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
|
||
def makeSetup(**args): | ||
|
@@ -257,7 +257,8 @@ def can_symlink(tmpdir): | |
os.remove(link_fn) | ||
|
||
|
||
def test_findall_missing_symlink(tmpdir, can_symlink): | ||
@pytest.mark.usefixtures("can_symlink") | ||
def test_findall_missing_symlink(tmpdir): | ||
with tmpdir.as_cwd(): | ||
os.symlink('foo', 'bar') | ||
found = list(setuptools.findall()) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'd like to see astral-sh/ruff#5157 or astral-sh/ruff#6840 before enabling
PT011