Hello there! Is there a reason that, when overriding a class method, e.g.class StopParsingEarlyAction(argparse.Action), I have to pedantically re-write
def __call__(
self,
parser: argparse.ArgumentParser,
namespace: argparse.Namespace,
values: str | Sequence[Any] | None,
option_string: str | None = None,
) -> NoReturn:even though "that's necessary by concept"? (I'm using --strict, error is no-untyped-def)
from typing import Any, ClassVar
from typing import overload
import datetime
import dateutil.tz._common
import dateutil.tz.tz
import dateutil.tz.tz.__get_gettz.<locals>
import pytz
UTC: pytz.UTC
dateutil_gettz: dateutil.tz.tz.__get_gettz.<locals>.GettzFunc
dst_cache: dict
import_optional_dependency: functionmypy says this is an error. Is this a bug in stubgen or is <locals> a real thing
def __get_gettz():
tzlocal_classes = (tzlocal,)
if tzwinlocal is not None:
tzlocal_classes += (tzwinlocal,)
class GettzFunc(object):
Callable[[str | None], datetime.tzinfo] to work, but maybe I'm missing something.
Hello there! I am wondering, what does that error mean?"Callable[..., None]" has no attribute "_original_name" [attr-defined] for the operation:func_new._original_name = func_new.__name__
I thought that, according to PEP 232 (https://peps.python.org/pep-0232/), you can "freely" set whatever attributes you wanted to functions 😕
sys.exit would be a -> NoReturn function, but IDE says it's -> None
_acquireLock and _releaseLock, which are missing 😕
--strict.type: ignore all over the place 😕
Also this output looks a little bit weird 😕
def func1(list_of_files: list[os.PathLike[Any]]) -> list[os.PathLike[Any]]:
scored = []
for file in list_of_files:
reveal_type(file)
scored.append({"json": file, "score": random.randint(0, 9)})
reveal_type(scored[0]["json"])
return [scored_file["json"] for scored_file in scored]
# test.py: note: In function "func1":
# test.py:12: note: Revealed type is "os.PathLike[Any]"
# test.py:15: note: Revealed type is "builtins.object"
# test.py:16: error: List comprehension has incompatible type List[object]; expected List[PathLike[Any]] [misc]Is it just me (i.e., can someone explain this to me), or is this a (known) issue of mypy? 😕
I'm trying to resolve arg-types using decorators, but not having any luck. Consider the following;
from typing import Dict, Optional
class Stuff:
config: Optional[Dict] = None
def __init__(self):
pass
class Runner:
def __init__(self):
pass
def method(self, config: Dict):
"""docstring"""
print(type(config))
print(config)
def decorator(func):
def wrapper(*args, **kwargs):
if not args[0].config:
raise Exception("config may not be None")
return func(*args, **kwargs)
return wrapper
@decorator
def func(stuff: Stuff):
runner = Runner()
runner.method(stuff.config)
def main():
stuff = Stuff()
stuff.config = None
func(stuff)I getmypy_issue.py:33: error: Argument 1 to "method" of "Runner" has incompatible type "Optional[Dict[Any, Any]]"; expected "Dict[Any, Any]" [arg-type]
funcI don't get the mypy issue
f(Bad()) since the parameter name on the method is wrong and won't work when f() calls p.m(x=3) that mypy isn't complaining about?
scored: list[DSTypedDict] = []?
ExtendedTraverserVisitor)
Hey :) Just a quick question: suppose I construct a set of classes like those below, such that I know MyClassInt is the only subclass of MyClass[Int].
class MyClass(Generic[T], ABC):
...
class MyClassInt(MyClass[Int]):
...Given this condition, MyClassInt and MyClass[Int] should be usable as type aliases for each other.
I'm wondering if there's a way (possibly through a MyPy plugin) to declare such equivalences / rewrite rules? Essentially this would amount to allowing downcasts from MyClass[Int] to MyClassInt (which would always be safe as MyClassInt is the only non-abstract class under MyClass[Int]).
Overloaded function implementation does not accept all possible arguments of signature 1 [misc]. T = TypeVar("T")
@overload
def param(self, name: str) -> Any:
...
@overload
def param(self, typ: Type[T], name: str) -> T:
...
def param(self, typ: Type[T] | str, name: Optional[str]) -> T | Any:
pass