Skip to content

Conversation

@MeGaGiGaGon
Copy link
Contributor

Summary

Part of #18972

Both in one PR since they are in the same file

No playground links since the playground does not support rules that only apply to PYI files

PYI014

This PR makes argument-default-in-stub (PYI014)'s example error out-of-the-box

Old example:

PS ~\Desktop\New_folder\ruff>echo @"
def foo(arg=[]) -> None: ...
"@ | uvx ruff check --isolated --preview --select PYI014 --stdin-filename "test.pyi" -
All checks passed!

New example:

PS ~\Desktop\New_folder\ruff>echo @"
def foo(arg=bar()) -> None: ...
"@ | uvx ruff check --isolated --preview --select PYI014 --stdin-filename "test.pyi" -
test.pyi:1:13: PYI014 [*] Only simple default values allowed for arguments
  |
1 | def foo(arg=bar()) -> None: ...
  |             ^^^^^ PYI014
  |
  = help: Replace default value with `...`

Found 1 error.
[*] 1 fixable with the `--fix` option.

PYI015

This PR makes assignment-default-in-stub (PYI015)'s example error out-of-the-box

Old example:

PS ~\Desktop\New_folder\ruff>echo @"
foo: str = "..."
"@ | uvx ruff check --isolated --preview --select PYI015 --stdin-filename "test.pyi" -
All checks passed!

New example:

PS ~\Desktop\New_folder\ruff>echo @"
foo: str = bar()
"@ | uvx ruff check --isolated --preview --select PYI015 --stdin-filename "test.pyi" -
test.pyi:1:12: PYI015 [*] Only simple default values allowed for assignments
  |
1 | foo: str = bar()
  |            ^^^^^ PYI015
  |
  = help: Replace default value with `...`

Found 1 error.
[*] 1 fixable with the `--fix` option.

Test Plan

N/A, no functionality/tests affected

@github-actions
Copy link
Contributor

github-actions bot commented Jul 2, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@AlexWaygood AlexWaygood merged commit d0f0577 into astral-sh:main Jul 3, 2025
35 checks passed
@AlexWaygood AlexWaygood added the documentation Improvements or additions to documentation label Jul 3, 2025
@MeGaGiGaGon MeGaGiGaGon deleted the patch-2 branch July 3, 2025 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants