python / python/mypy

Optionally flag known mypyc compatibility issues in mypy

Offen
#14,715 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

feature topic-mypyc
Vorherrschende Sprache
Python
Sterne
20.6k
Forks
3.3k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

Feature

Mypyc is incompatible in some ways with CPython semantics (mypyc/mypyc#973 is a recent example). Add an optional error code to mypy that detects some of these incompatible features in code even when not using mypyc. We can also explain how to work around the issues in notes, or include links to documentation.

Here are some issues we could flag:

  • Overriding methods in subclasses of built-in types such as int or str that mypyc can't use.
  • Subclassing compiled classes that don't support interpreted subclasses. This would require knowledge of which modules will be compiled.
  • Monkey patching native functions or methods. This is usually flagged already by mypy, but we could perhaps detect this in additional cases, add a note about mypyc when relevant, and use a separate error code.

Pitch

Code that isn't compiled with mypyc can trigger incompatible behavior or exceptions when interacting with mypyc-compiled modules, and this is confusing. These messages would make it easier to avoid using things that may cause issues with mypyc, if part of a project is compiled with mypyc.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit der Durchsicht des Beispiels mypyc#973 und der vorhandenen Diagnosen von mypy für Monkey-Patching. Lege den Umfang eines optionalen Fehlercodes für Überschreibungen von Unterklassen integrierter Typen, die Unterklassenbildung von kompilierten Klassen und relevantes Monkey-Patching fest, einschließlich etwaiger Hinweise oder Dokumentationslinks. Als abgeschlossen gilt die Arbeit, wenn die ausgewählten Inkompatibilitäten erkannt werden, ohne mypyc zu benötigen, und das Verhalten durch Tests abgedeckt ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
compilers
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.