Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Uninhabited should have all attributes#19300

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
JukkaL merged 3 commits intopython:masterfromilevkivskyi:attr-never
Jul 18, 2025

Conversation

@ilevkivskyi
Copy link
Member

Although this can hide some mypy bugs, TBH this always bothered me as something conceptually wrong. The work oncheckmember stuff inspired me to actually try it.

@ilevkivskyiilevkivskyi requested a review fromJukkaLJune 14, 2025 19:20
@github-actions

This comment has been minimized.

@sterliakov
Copy link
Collaborator

For me"Never" has no attribute "foo" is an early indicator of failed/impossible inference. Allowing arbitrary lookups onNever may prevent that from happening, potentially breaking some funny typing patterns likeNever-returning overloads. This will be even more painful for users who don't runmypy with--warn-unreachable enabled.

While I understand your motivation, I think it's completely impractical here. Furthermore, if I'm not mistaken, the"Never" not callable error is no better than"Never" has no attribute "foo" - it's as safe to callNever as it is to access attributefoo on it. Allowing one but not another is an inconsistency and source of confusion. Allowing both can hide too many issues.

@A5rocks
Copy link
Collaborator

A5rocks commentedJun 16, 2025
edited
Loading

I think this change is good (and there's like 2 other similar places), especially if combined something that marks any block with a variable bound to Never as unreachable.

Edit: Nevermind I see you address that w/r/twarn-unreachable not being set. I don't think this is actually an actionable error message though? Like, "ok so my variable is Never" doesn't convey much especially to those not familiar with mypy internals.

@sterliakov
Copy link
Collaborator

marks any block with a variable bound to Never as unreachable.

Well, then we won't see "Never has no attribute ..." at all, so it doesn't really matter whether such attribute access is allowed?

I see some merit in saying "we do indicate some important issues via[unreachable] errors, please keep them enabled", but it's easier said than done - notably some parts ofmypy itself still don't pass--warn-unreachable AFAIC.

@ilevkivskyi
Copy link
MemberAuthor

the"Never" not callable error is no better

Yes, I think we should actually enable that one as well. I am actually going to try that now.

@github-actions
Copy link
Contributor

Diff frommypy_primer, showing the effect of this PR on open source code:

Tanjun (https://github.com/FasterSpeeding/Tanjun)- tanjun/clients.py:2294: error: "Never" has no attribute "__iter__" (not iterable)  [attr-defined]ibis (https://github.com/ibis-project/ibis)- ibis/expr/types/relations.py:1041: error: "Never" has no attribute "__next__"  [attr-defined]prefect (https://github.com/PrefectHQ/prefect)- src/prefect/server/models/deployments.py:63: error: "Never" has no attribute "name"  [attr-defined]- src/prefect/server/models/deployments.py:767: error: "Never" has no attribute "model_dump"  [attr-defined]manticore (https://github.com/trailofbits/manticore)+ manticore/wasm/types.py:56: error: Unused "type: ignore" comment  [unused-ignore]xarray (https://github.com/pydata/xarray)+ xarray/core/variable.py:922: error: Unused "type: ignore" comment  [unused-ignore]+ xarray/core/variable.py:924: error: Unused "type: ignore" comment  [unused-ignore]+ xarray/core/variable.py:2807: error: Unused "type: ignore" comment  [unused-ignore]+ xarray/core/variable.py:2809: error: Unused "type: ignore" comment  [unused-ignore]

Copy link
Collaborator

@sterliakovsterliakov left a comment

Choose a reason for hiding this comment

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

This seems consistent now. I'm still not the biggest fan of this idea, but I have--warn-unreachable enabled everywhere so shouldn't be bitten too painfully.

Copy link
Collaborator

@JukkaLJukkaL left a comment

Choose a reason for hiding this comment

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

I agree that this is the most consistent way to do this. There are probably various other cases where we don't handleNoReturn, but this moves us into the right direction and covers many common cases.

JelleZijlstra reacted with thumbs up emoji
@JukkaLJukkaL merged commitabb1cc7 intopython:masterJul 18, 2025
19 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@JukkaLJukkaLJukkaL approved these changes

+1 more reviewer

@sterliakovsterliakovsterliakov approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@ilevkivskyi@sterliakov@A5rocks@JukkaL

[8]ページ先頭

©2009-2025 Movatter.jp