python / python/mypy

Followup tasks for checkmember.py refactoring

Aperta
#19,299 2 commenti 0 reazioni 1 assegnatario Vedi su GitHub

@ilevkivskyi ci sta già lavorando.

Dal 14/6/2025.

meta priority-1-normal refactoring
Lingua principale
Python
Stelle
20.6k
Fork
3.3k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

These are some of the remaining tasks after https://github.com/python/mypy/issues/7724 is done. These are either somewhat tricky and/or somewhat boring and/or less pressing. In no particular order:

  • We should cleanup/unify attribute writeability logic when checking overrides and subtyping. Most notably:
    • Multiple inheritance is quite messy in this regard.
    • Descriptors with custom __set__() should follow the same logic (including use of mutable-override error code) as properties with custom setters in protocol subtyping and LSP checks.
  • We need to set type_checker in more places to benefit from the new (complete) logic for find_member(), most notable in semanal_typeargs.py and in post-semanal plugins.
  • Now that all attribute access is going through checkmember we should refactor it itself. Couple ideas:
    • Merge bind_self() and check_self_arg()
    • Generalize/extend analyze_decorator_or_funcbase_access()
    • Cleanup class attribute access and unify it with instance attribute access
  • We should re-think how deferrals work, and re-enable some deferrals that are currently skipped (current logic is too limited, we stop all inference after first deferral, and can't defer module scope). The new logic may be like this:
    • We can defer either a module scope or a top-level function (similar to fine-grained incremental)
    • Use "sticky" (i.e. propagating to nested nodes) flag to suppress Any-related error reporting
    • Use new TypeOfAny to suppress inferring bogus Any types for variables
    • Update all isinstance()-like checks to handle this new kind of Any
  • Cleanup Var (and related RefExpr and AssignmentStmt) flags. There are way too many of them, and some of them are used inconsistently.
  • Couple pedantic things we shouldn't even do:
    • Check class level access for descriptor overrides
    • Take into account __getattr__() for LSP checks

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.