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

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

Merged
merged 2 commits into from Apr 18, 2024

Conversation

charliermarsh
Copy link
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 Something isn't working label Apr 18, 2024
Copy link
Contributor

github-actions bot commented Apr 18, 2024

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

Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

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

Yeah, this makes sense!

@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 Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PLE0307 triggers on __str__ that always raises an exception
2 participants