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

Skip empty lines when determining base indentation #9795

Merged
merged 2 commits into from
Feb 2, 2024
Merged

Conversation

charliermarsh
Copy link
Member

Summary

It turns out we saw a panic in cases when dedenting blocks like the def wrapper here:

def instrument_url(f: UrlFuncT) -> UrlFuncT:
    # TODO: Type this with ParamSpec to preserve the function signature.
    if not INSTRUMENTING:  # nocoverage -- option is always enabled; should we remove?
        return f
    else:

        def wrapper(
            self: "ZulipTestCase", url: str, info: object = {}, **kwargs: Union[bool, str]
        ) -> HttpResponseBase:

Since we relied on the first line to determine the indentation, instead of the first non-empty line.

Test Plan

cargo test

@charliermarsh charliermarsh added the bug Something isn't working label Feb 2, 2024
@charliermarsh charliermarsh marked this pull request as ready for review February 2, 2024 19:16
Copy link
Contributor

github-actions bot commented Feb 2, 2024

ruff-ecosystem results

Linter (stable)

ℹ️ ecosystem check encountered linter errors. (no lint changes; 1 project error)

sphinx-doc/sphinx (error)

ruff failed
  Cause: Selection of unstable rules without the `--preview` flag is not allowed. Enable preview or remove selection of:
	- FURB113
	- FURB131
	- FURB132

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+530 -0 violations, +0 -0 fixes in 2 projects; 41 projects unchanged)

apache/airflow (+342 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select ALL

+ tests/utils/test_task_group.py:1001:9: ANN202 Missing return type annotation for private function `task_1`
+ tests/utils/test_task_group.py:1003:9: T201 `print` found
+ tests/utils/test_task_group.py:1006:9: ANN202 Missing return type annotation for private function `task_2`
+ tests/utils/test_task_group.py:1008:9: T201 `print` found
+ tests/utils/test_task_group.py:1011:9: ANN202 Missing return type annotation for private function `task_3`
+ tests/utils/test_task_group.py:1013:9: T201 `print` found
+ tests/utils/test_task_group.py:1016:9: ANN202 Missing return type annotation for private function `task_group1`
+ tests/utils/test_task_group.py:1022:9: ANN202 Missing return type annotation for private function `task_group2`
+ tests/utils/test_task_group.py:1026:9: ANN202 Missing return type annotation for private function `task_group3`
... 65 additional changes omitted for rule ANN202
+ tests/utils/test_task_group.py:1050:5: S101 Use of `assert` detected
+ tests/utils/test_task_group.py:1053:5: ANN201 Missing return type annotation for public function `test_call_taskgroup_twice`
+ tests/utils/test_task_group.py:1055:5: PLC0415 `import` should be at the top-level of a file
+ tests/utils/test_task_group.py:1060:9: T201 `print` found
+ tests/utils/test_task_group.py:1065:9: T201 `print` found
+ tests/utils/test_task_group.py:1071:9: T201 `print` found
... 15 additional changes omitted for rule T201
+ tests/utils/test_task_group.py:1107:5: S101 Use of `assert` detected
+ tests/utils/test_task_group.py:1110:5: ANN201 Missing return type annotation for public function `test_pass_taskgroup_output_to_task`
+ tests/utils/test_task_group.py:1112:5: PLC0415 `import` should be at the top-level of a file
+ tests/utils/test_task_group.py:1119:29: ANN001 Missing type annotation for function argument `num`
+ tests/utils/test_task_group.py:1121:21: ANN001 Missing type annotation for function argument `i`
+ tests/utils/test_task_group.py:1127:19: ANN001 Missing type annotation for function argument `num`
+ tests/utils/test_task_group.py:1133:9: S101 Use of `assert` detected
+ tests/utils/test_task_group.py:1135:9: S101 Use of `assert` detected
+ tests/utils/test_task_group.py:1137:9: S101 Use of `assert` detected
+ tests/utils/test_task_group.py:1142:5: ANN201 Missing return type annotation for public function `test_decorator_unknown_args`
+ tests/utils/test_task_group.py:1151:5: ANN201 Missing return type annotation for public function `test_decorator_multiple_use_task`
+ tests/utils/test_task_group.py:1152:5: PLC0415 `import` should be at the top-level of a file
+ tests/utils/test_task_group.py:1168:5: S101 Use of `assert` detected
... 101 additional changes omitted for rule S101
+ tests/utils/test_task_group.py:1177:5: ANN201 Missing return type annotation for public function `test_topological_sort1`
+ tests/utils/test_task_group.py:1184:9: AIR001 Task variable name should match the `task_id`: "A"
+ tests/utils/test_task_group.py:1185:9: AIR001 Task variable name should match the `task_id`: "B"
+ tests/utils/test_task_group.py:1186:9: AIR001 Task variable name should match the `task_id`: "C"
... 310 additional changes omitted for project

zulip/zulip (+188 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select ALL

+ zerver/lib/test_helpers.py:100:44: FA100 Missing `from __future__ import annotations`, but uses `typing.Optional`
+ zerver/lib/test_helpers.py:100:69: FA100 Missing `from __future__ import annotations`, but uses `typing.Optional`
+ zerver/lib/test_helpers.py:100:78: FA100 Missing `from __future__ import annotations`, but uses `typing.Dict`
+ zerver/lib/test_helpers.py:104:33: FA100 Missing `from __future__ import annotations`, but uses `typing.List`
+ zerver/lib/test_helpers.py:104:56: FA100 Missing `from __future__ import annotations`, but uses `typing.Optional`
+ zerver/lib/test_helpers.py:104:81: FA100 Missing `from __future__ import annotations`, but uses `typing.Dict`
... 50 additional changes omitted for rule FA100
+ zerver/lib/test_helpers.py:113:5: D103 Missing docstring in public function
+ zerver/lib/test_helpers.py:121:58: COM812 [*] Trailing comma missing
+ zerver/lib/test_helpers.py:131:7: D101 Missing docstring in public class
+ zerver/lib/test_helpers.py:138:39: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/test_helpers.py:138:39: FBT002 Boolean default positional argument in function definition
+ zerver/lib/test_helpers.py:138:5: FBT001 Boolean-typed positional argument in function definition
+ zerver/lib/test_helpers.py:138:5: FBT002 Boolean default positional argument in function definition
+ zerver/lib/test_helpers.py:138:68: COM812 [*] Trailing comma missing
+ zerver/lib/test_helpers.py:140:5: D202 [*] No blank lines allowed after function docstring (found 1)
+ zerver/lib/test_helpers.py:140:5: D205 1 blank line required between summary line and description
+ zerver/lib/test_helpers.py:140:5: D212 [*] Multi-line docstring summary should start at the first line
... 171 additional changes omitted for project

Changes by rule (53 rules affected)

code total + violation - violation + fix - fix
S101 117 117 0 0 0
ANN202 70 70 0 0 0
FA100 55 55 0 0 0
AIR001 40 40 0 0 0
ANN201 38 38 0 0 0
ANN001 28 28 0 0 0
D103 24 24 0 0 0
T201 23 23 0 0 0
PLC0415 18 18 0 0 0
COM812 14 14 0 0 0
SIM117 12 12 0 0 0
FBT001 6 6 0 0 0
FBT002 5 5 0 0 0
PT012 5 5 0 0 0
PTH118 5 5 0 0 0
PTH123 4 4 0 0 0
FIX002 4 4 0 0 0
TD002 4 4 0 0 0
TD003 4 4 0 0 0
D106 4 4 0 0 0
RET505 3 3 0 0 0
D101 3 3 0 0 0
D205 3 3 0 0 0
ANN401 3 3 0 0 0
B015 2 2 0 0 0
CPY001 2 2 0 0 0
D202 2 2 0 0 0
D212 2 2 0 0 0
PLW1514 2 2 0 0 0
D107 2 2 0 0 0
D400 2 2 0 0 0
D415 2 2 0 0 0
C408 2 2 0 0 0
PERF401 1 1 0 0 0
A002 1 1 0 0 0
A001 1 1 0 0 0
D100 1 1 0 0 0
D401 1 1 0 0 0
D404 1 1 0 0 0
PTH100 1 1 0 0 0
PTH120 1 1 0 0 0
D209 1 1 0 0 0
PLR0913 1 1 0 0 0
PLR0917 1 1 0 0 0
C901 1 1 0 0 0
PLR0915 1 1 0 0 0
PLR1702 1 1 0 0 0
PLR6201 1 1 0 0 0
PLR2004 1 1 0 0 0
TD004 1 1 0 0 0
RET504 1 1 0 0 0
PLR0914 1 1 0 0 0
ARG001 1 1 0 0 0

Formatter (stable)

ℹ️ ecosystem check encountered format errors. (no format changes; 2 project errors)

sphinx-doc/sphinx (error)

ruff format --no-preview --exclude tests/roots/test-pycode/cp_1251_coded.py

ruff failed
  Cause: Selection of unstable rules without the `--preview` flag is not allowed. Enable preview or remove selection of:
	- FURB113
	- FURB131
	- FURB132

openai/openai-cookbook (error)

warning: Detected debug build without --no-cache.
error: Failed to parse examples/dalle/Image_generations_edits_and_variations_with_DALL-E.ipynb:3:7:8: Unexpected token 'prompt'

Formatter (preview)

ℹ️ ecosystem check encountered format errors. (no format changes; 1 project error)

openai/openai-cookbook (error)

ruff format --preview

warning: Detected debug build without --no-cache.
error: Failed to parse examples/dalle/Image_generations_edits_and_variations_with_DALL-E.ipynb:3:7:8: Unexpected token 'prompt'

@charliermarsh
Copy link
Member Author

Ecosystem checks are correct. I accidentally merged #9769 previously which removed all of those rules because we started panicking on those specific files.

@charliermarsh charliermarsh enabled auto-merge (squash) February 2, 2024 19:37
@charliermarsh charliermarsh merged commit ee5b07d into main Feb 2, 2024
17 checks passed
@charliermarsh charliermarsh deleted the charlie/s branch February 2, 2024 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants