Skip to content

[ty]: make possibly-missing-attribute ignored by default#23918

Merged
oconnor663 merged 2 commits intomainfrom
jack/disable-possibly-missing-attribute
Mar 12, 2026
Merged

[ty]: make possibly-missing-attribute ignored by default#23918
oconnor663 merged 2 commits intomainfrom
jack/disable-possibly-missing-attribute

Conversation

@oconnor663
Copy link
Contributor

Fixes astral-sh/ty#2244. Two commits in this PR:


[ty]: split out possibly-missing-submodule from possibly-missing-attribute


[ty]: make possibly-missing-attribute ignored by default

This warning has a lot of false positives, and other typecheckers don't
report it. The previous commit split out possibly-missing-submodule as
a separate default-on warning, which was our last blocker for disabling
this one.


Example

.
├── foo.py
└── bar
    ├── __init__.py
    └── baz.py

foo.py:

import bar

bar.x
bar.baz

bar/__init__.py:

def random():
    pass

if random():
    x = 42

bar/baz.py is just an empty file.

Before this PR we have possibly-missing-attribute on both accesses:

$ ty check .
warning[possibly-missing-attribute]: Member `x` may be missing on module `bar`
 --> foo.py:3:1
  |
1 | import bar
2 |
3 | bar.x
  | ^^^^^
4 | bar.baz
  |
info: rule `possibly-missing-attribute` is enabled by default

warning[possibly-missing-attribute]: Submodule `baz` may not be available as an attribute on module `bar`
 --> foo.py:4:1
  |
3 | bar.x
4 | bar.baz
  | ^^^^^^^
  |
help: Consider explicitly importing `bar.baz`
info: rule `possibly-missing-attribute` is enabled by default

Found 2 diagnostics

After this PR the variable access doesn't get a diagnostic, and we have possibly-missing-submodule on the module access:

$ ty check .
warning[possibly-missing-submodule]: Submodule `baz` might not have been imported
 --> foo.py:4:1
  |
3 | bar.x
4 | bar.baz
  | ^^^^^^^
  |
help: Consider explicitly importing `bar.baz`
info: rule `possibly-missing-submodule` is enabled by default

Found 1 diagnostic

@astral-sh-bot
Copy link

astral-sh-bot bot commented Mar 12, 2026

Typing conformance results

No changes detected ✅

Current numbers
The percentage of diagnostics emitted that were expected errors held steady at 85.29%. The percentage of expected errors that received a diagnostic held steady at 78.13%. The number of fully passing files held steady at 64/132.

@AlexWaygood AlexWaygood added the ty Multi-file analysis & type inference label Mar 12, 2026
@astral-sh-bot
Copy link

astral-sh-bot bot commented Mar 12, 2026

Memory usage report

Memory usage unchanged ✅

Copy link
Contributor

@carljm carljm left a comment

Choose a reason for hiding this comment

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

Needs a cargo dev generate-all, but otherwise looks good.

@AlexWaygood
Copy link
Member

Do we know why mypy_primer timed out?

Copy link
Member

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

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

We should explicitly enable the rule for our mypy primer runs here

https://github.com/astral-sh/ruff/blob/6e88957d56b91befbc384f7e235813d300d512ff/.github/mypy-primer-ty.toml#L10

This should also fix the mypy primer timeout

@oconnor663
Copy link
Contributor Author

@MichaReiser done, thanks for the tip. Was the timeout just because the diagnostics diff was too large?

@AlexWaygood
Copy link
Member

Was the timeout just because the diagnostics diff was too large?

Oh that could definitely be it! You could try running ecosystem-analyzer to be sure — I think its diffing logic has less pathological performance than mypy_primer IIRC?

@astral-sh-bot
Copy link

astral-sh-bot bot commented Mar 12, 2026

ecosystem-analyzer results

Lint rule Added Removed Changed
possibly-missing-submodule 1,488 0 0
possibly-missing-attribute 0 1,481 0
invalid-await 0 40 0
unused-type-ignore-comment 0 2 0
invalid-return-type 0 1 0
Total 1,488 1,524 0

Full report with detailed diff (timing results)

@oconnor663
Copy link
Contributor Author

Hmm even with the config change mypy primer times out still. Any chance that's expected with ~1500 diagnostics switched around? (Aside: all the small ecosystem changes are flakes according to ecosystem analyzer.)

@AlexWaygood
Copy link
Member

Any chance that's expected with ~1500 diagnostics switched around?

Yes, it is — since ecosystem-analyzer passed without reporting any timeouts, I don't think you need to worry about it :-) it's just a huge diff that's too much for Python's stdlib difflib module, which doesn't have a great time complexity for pathological inputs

This warning has a lot of false positives, and other typecheckers don't
report it. The previous commit split out `possibly-missing-submodule` as
a separate default-on warning, which was our last blocker for disabling
this one.
@oconnor663 oconnor663 force-pushed the jack/disable-possibly-missing-attribute branch from bf72926 to 55fc4e4 Compare March 12, 2026 23:42
@oconnor663 oconnor663 enabled auto-merge (rebase) March 12, 2026 23:43
@oconnor663 oconnor663 merged commit a9a544c into main Mar 12, 2026
49 of 50 checks passed
@oconnor663 oconnor663 deleted the jack/disable-possibly-missing-attribute branch March 12, 2026 23:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ecosystem-analyzer ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Member <anything> may be missing on module torch.distributed

5 participants