With `--disallow-any-decorated`, `Any` detection logic changes w/wo decorator
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 38/100
Piste de recherche
Commencez par exécuter le cas de test testDisallowAnyDecoratedShouldNeverAffect avec --disallow-any-decorated et le fixture builtins fixtures/classmethod.pyi fourni. Comparez les cas non décoré, classmethod et décorateur personnalisé, puis rendez le comportement cohérent et couvrez la condition d’erreur choisie avec des tests de régression.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Bug Report
(A clear and concise description of what the bug is.)
We expect that adding a decorator to a method will never produce a new mypy error unless the decorator itself introduces a new Any annotation, i.e. expect no new error if the decorator itself does not introduce any additional Any.
We also believe that it is difficult to call this behavior a bug. The behavior of the option itself seems self-evident in its own way.
But we would expect a situation where simply applying a harmless decorator would not change the presence or absence of errors.
To Reproduce
Here is a test case.
[case testDisallowAnyDecoratedShouldNeverAffect]
# flags: --disallow-any-decorated
import dataclasses
from typing import Any, Callable
from typing_extensions import TypedDict, TypeVar
class CtxAny(TypedDict):
place: Any
CallableT = TypeVar("CallableT")
def custom_decorator(func: CallableT) -> CallableT:
return func
class Something:
# No error
def do(self, ctx: CtxAny) -> None:
pass
@classmethod
# This emits an error, unexpected.
def do_classmethod(cls, ctx: CtxAny) -> None: # E: Type of decorated function contains type "Any" ("Callable[[Type[Something], CtxAny], None]")
pass
@custom_decorator
# This emits an error, unexpected.
def do_custom_decorator(self, ctx: CtxAny) -> None: # E: Type of decorated function contains type "Any" ("Callable[[Something, CtxAny], None]")
pass
[builtins fixtures/classmethod.pyi]
Expected Behavior
We expect do and others to be the same error-condition.
i.e. one of:
- No mypy errors emitted.
- All (containing
domethod) emits an error.- If some option allows us to emit an error on
domethod, it will be fine.
- If some option allows us to emit an error on
Actual Behavior
As shown in reproduction code.
Your Environment
- Mypy version used:current master
- Mypy command-line flags:
--disallow-any-decorated - Mypy configuration options from
mypy.ini(and other config files): - Python version used: 3.8.16, 3.11.3
- Langage dominant
- Python
- Étoiles
- 20.6k
- Forks
- 3.3k
- Merge moyen
- 1 j 18 h
- PR mergées (30 j)
- 54
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de python/mypy
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
-
documentation
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
-
bug topic-configuration topic-error-reporting
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
Toutes les issues de python/mypy
Issues similaires
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 86/100
zostera/django-bootstrap4#894 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
use-agent-os/agent-os#3276 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
zephyrproject-rtos/zephyr#119726 ·
-
area/auth bug comp/agent P3 platform/discord type/security
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
NousResearch/hermes-agent#117848 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
zilliztech/memsearch#759 ·