Skip to content

Allow NoReturn-like functions for __str__, __len__, etc. - #11017

Merged
charliermarsh merged 2 commits into
mainfrom
charlie/raise
Apr 18, 2024
Merged

charliermarsh merged 2 commits into
mainfrom
charlie/raise

Conversation

@charliermarsh

Copy link
Copy Markdown
Member

Summary

If the method always raises, we shouldn't raise a diagnostic for "returning a value of the wrong type".

Closes #11016.

@charliermarsh charliermarsh added the bug An issue describing something that isn't working, or a PR that fixes a bug label Apr 18, 2024
@github-actions

github-actions Bot commented Apr 18, 2024 •

Copy link
Copy Markdown
Contributor

ruff-ecosystem results

Linter (stable)

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

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

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

- zerver/lib/validator.py:684:9: PLE0307 `__str__` does not return `str`

indico/indico (+1 -0 violations, +0 -0 fixes)

+ indico/util/passwords.py:69:25: RUF100 [*] Unused `noqa` directive (unused: `PLE0307`)

Changes by rule (2 rules affected)

code total + violation - violation + fix - fix
RUF100 1 1 0 0 0
PLE0307 1 0 1 0 0

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+1 -8 violations, +0 -0 fixes in 6 projects; 38 projects unchanged)

PlasmaPy/PlasmaPy (+0 -1 violations, +0 -0 fixes)

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

- src/plasmapy/particles/particle_class.py:174:9: PLE0304 `__bool__` does not return `bool`

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

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

- tests/models/test_mappedoperator.py:76:13: PLE0304 `__bool__` does not return `bool`

ibis-project/ibis (+0 -3 violations, +0 -0 fixes)

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

- ibis/common/deferred.py:101:9: PLE0304 `__bool__` does not return `bool`
- ibis/expr/types/core.py:166:9: PLE0304 `__bool__` does not return `bool`
- ibis/expr/types/relations.py:831:9: PLE0303 `__len__` does not return a non-negative integer

pandas-dev/pandas (+0 -2 violations, +0 -0 fixes)

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

- pandas/core/arrays/base.py:483:9: PLE0303 `__len__` does not return a non-negative integer
- pandas/core/base.py:349:9: PLE0303 `__len__` does not return a non-negative integer

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

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

- zerver/lib/validator.py:684:9: PLE0307 `__str__` does not return `str`

indico/indico (+1 -0 violations, +0 -0 fixes)

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

+ indico/util/passwords.py:69:25: RUF100 [*] Unused `noqa` directive (unused: `PLE0307`)

Changes by rule (4 rules affected)

code total + violation - violation + fix - fix
PLE0304 4 0 4 0 0
PLE0303 3 0 3 0 0
RUF100 1 1 0 0 0
PLE0307 1 0 1 0 0

@AlexWaygood AlexWaygood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this makes sense!

Comment thread crates/ruff_linter/resources/test/fixtures/pylint/invalid_return_type_str.py Outdated
@charliermarsh
charliermarsh enabled auto-merge (squash) April 18, 2024 22:45
…rn_type_str.py

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug An issue describing something that isn't working, or a PR that fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PLE0307 triggers on __str__ that always raises an exception

2 participants