You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The trick explained here used to make typegaurd use the runtime types but MyPy use the static-type-checking types sadly does not work with Pyright.
fromtypingimportTYPE_CHECKING, Any, TypeAlias, reveal_type_STATIC_TYPE_CHECKING=TYPE_CHECKING# workaround for typeguardif_STATIC_TYPE_CHECKING:
Foo: TypeAlias=Anyelse:
classMetaFoo(type):
def__instancecheck__(cls, obj):
...
classFoo(metaclass=MetaFoo): # type: ignore[no-redef]passifTYPE_CHECKING:
Bar: TypeAlias=Anyelse:
classMetaBar(type):
def__instancecheck__(cls, obj):
...
classBar(metaclass=MetaBar): # type: ignore[no-redef]passreveal_type(Foo) # pyright output: Type of "Foo" is "Type[Foo]"reveal_type(Bar) # pyright output: Type of "Bar" is "Any"
So this gives an error:
importinflectp=inflect.engine()
p.plural("apple") # Argument of type "Literal['apple']" cannot be assigned to parameter "text" of type "Word" in function "plural"# "Literal['apple']" is incompatible with "Word" [reportArgumentType]
The text was updated successfully, but these errors were encountered:
I'm sorry to hear that. I'm not sure there's much this project can do about the situation other than stop using Typeguard. This project switched from Pydantic to Typeguard in order to avoid expensive and compatibility-challenged dependencies. This project could, of course, fall back to classical imperative validation of parameters, which would be a substantial loss of sophistication in the code. Can I assume this report is a symptom of a larger issue to be addressed between Typeguard and Pyright?
@jaraco Maybe it's worth contacting the Pyright maintainers? From what I've seen they were often quite quick regarding replies to issues and might have input on how to solve this most elegantly if you describe what you want to achieve.
The trick explained here used to make typegaurd use the runtime types but MyPy use the static-type-checking types sadly does not work with Pyright.
So this gives an error:
The text was updated successfully, but these errors were encountered: