-
Notifications
You must be signed in to change notification settings - Fork 769
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how to suppress errors about a library with types set to 'UndefinedType'? #3210
Comments
I suggest if you want the benefits of type checking to change alternatively change
but then again you are losing the benefits of using actual types. see https://github.com/Microsoft/pylance-release#settings-and-customization
|
maybe the python typing group can help you |
Thanks @bschnurr!
This doesn't change the behavior (which makes sense since the typechecker's objection is that
In essence that's what I'm trying to accomplish with vega/altair#2670 (which does seem to solve my problem, if in an unpleasant fashion) |
closing for now |
Thanks @bschnurr ! Papertrail: vega/altair#2681 merged to solve my problem :-) |
I suspect this is an issue not quite due solely to pylance or to the library in question (
altair
) but to the interaction of the two...I am using pylance on a project that makes use of the altair data visualization library. Nearly every call to an altair method produces a pylance error about not assigning something to a parameter of type
UndefinedType
.For example, altair's
chart
method takes apandas.DataFrame
object as an argument:However, the call to
altair.Chart
produces the following pylance error:For context, I believe what is happening is that the altair library has defined a class
UndefinedType
of whichUndefined
is an instance: https://github.com/altair-viz/altair/blob/137a6e52efd2cc38a9ba4fbba1c6a7e0a75801bc/altair/utils/schemapi.py#L126-L140And then the
alt.Chart
method has an argument withUndefined
as the default value, so the typer is inferringUndefinedType
as the expected type of the argument.Is there any way to suppress this class of errors arising from the altair library? For example, is there some way to tell pylance to treat
UndefinedType
(which is not exported as far as I can tell) as equivalent toAny
? (vega/altair#2670 is my attempt to do so directly, but it seems like it might be preferable to make this sort of change at the level of the typer instead.)Environment data
Error details
The text was updated successfully, but these errors were encountered: