Skip to content
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

alt.Color fails mypy --strict with error: Call to untyped function "Color" in typed context [no-untyped-call] #3408

Open
wyattscarpenter opened this issue Apr 22, 2024 · 4 comments · May be fixed by #3414
Assignees
Labels

Comments

@wyattscarpenter
Copy link

wyattscarpenter commented Apr 22, 2024

What happened?

I use altair in my project, which is typedchecked with mypy strict mode. When I have a graph in that project which uses alt.Color, I get error: Call to untyped function "Color" in typed context [no-untyped-call] from mypy --strict. Oddly, this does not happen to other alt.Whatever objects, only color. I can't be sure if this is an altair bug or a mypy bug, to be honest.

Here's a minimal example:

import altair as alt
import pandas as pd
dicted_rows = {"a": [1, 2, 3], "b": [4, 5, 6], "c": ["red", "blue", "yellow"]}
chart = alt.Chart(pd.DataFrame(dicted_rows)).mark_circle(size=90).encode(alt.X("a"), alt.Y("b"), alt.Color("c"))
chart.save('chart.html') #note: this works fine

Results from mypy version 1.9.0 (compiled: yes):

$ mypy "minimal altair example.py"
Success: no issues found in 1 source file
$ mypy --strict "minimal altair example.py"
minimal altair example.py:4: error: Call to untyped function "Color" in typed context  [no-untyped-call]
Found 1 error in 1 file (checked 1 source file)

What would you like to happen instead?

The types should be annotated appropriately so Color is deduced to be a typed function and therefore mypy strict would not report an error.

I'm not sure exactly what this would involve. https://peps.python.org/pep-0484/ says the return type of init ought to be None, so that's somewhere to start, maybe, perhaps.

Which version of Altair are you using?

5.3.0

@binste
Copy link
Contributor

binste commented Apr 24, 2024

Weird, Color is type annotated in the same way as other encoding channels such as X and Y. Maybe mypy somehow gets confused... Thanks for raising it! I'll have a look.

@wyattscarpenter
Copy link
Author

It also seems to fail pyright, erroring for all three arguments.

In case it helps, here's the output from various type checkers, using reveal_type on alt.X, alt.Y, and alt.Color, and some other parts as well:

import altair as alt
import pandas as pd
dicted_rows = {"a": [1, 2, 3], "b": [4, 5, 6], "c": ["red", "blue", "yellow"]}
chart = alt.Chart(pd.DataFrame(dicted_rows)).mark_circle(size=90).encode(alt.X("a"), alt.Y("b"), alt.Color("c"))
chart.save('chart.html') #note: this works fine
reveal_type(alt.X)
reveal_type(alt.Y)
reveal_type(alt.Color)
reveal_type(alt.Chart)
reveal_type(alt.Chart(pd.DataFrame(dicted_rows)).mark_circle(size=90))
reveal_type(alt.Chart(pd.DataFrame(dicted_rows)).mark_circle(size=90).encode)

pyright 1.1.360:

c:\experiment\minalt.py
  c:\experiment\minalt.py:4:74 - error: Argument of type "X" cannot be assigned to parameter "angle" of type "str | Angle | dict[Unknown, Unknown] | AngleDatum | AngleValue | UndefinedType"
    Type "X" is incompatible with type "str | Angle | dict[Unknown, Unknown] | AngleDatum | AngleValue | UndefinedType"
      "X" is incompatible with "str"
      "X" is incompatible with "Angle"
      "X" is incompatible with "dict[Unknown, Unknown]"
      "X" is incompatible with "AngleDatum"
      "X" is incompatible with "AngleValue"
      "X" is incompatible with "UndefinedType" (reportArgumentType)
  c:\experiment\minalt.py:4:86 - error: Argument of type "Y" cannot be assigned to parameter "color" of type "str | Color | dict[Unknown, Unknown] | ColorDatum | ColorValue | UndefinedType"
    Type "Y" is incompatible with type "str | Color | dict[Unknown, Unknown] | ColorDatum | ColorValue | UndefinedType"
      "Y" is incompatible with "str"
      "Y" is incompatible with "Color"
      "Y" is incompatible with "dict[Unknown, Unknown]"
      "Y" is incompatible with "ColorDatum"
      "Y" is incompatible with "ColorValue"
      "Y" is incompatible with "UndefinedType" (reportArgumentType)
  c:\experiment\minalt.py:4:98 - error: Argument of type "Color" cannot be assigned to parameter "column" of type "str | Column | dict[Unknown, Unknown] | UndefinedType"
    Type "Color" is incompatible with type "str | Column | dict[Unknown, Unknown] | UndefinedType"
      "Color" is incompatible with "str"
      "Color" is incompatible with "Column"
      "Color" is incompatible with "dict[Unknown, Unknown]"
      "Color" is incompatible with "UndefinedType" (reportArgumentType)
  c:\experiment\minalt.py:6:13 - information: Type of "alt.X" is "type[X]"
  c:\experiment\minalt.py:7:13 - information: Type of "alt.Y" is "type[Y]"
  c:\experiment\minalt.py:8:13 - information: Type of "alt.Color" is "type[Color]"
  c:\experiment\minalt.py:9:13 - information: Type of "alt.Chart" is "type[Chart]"
  c:\experiment\minalt.py:10:13 - information: Type of "alt.Chart(pd.DataFrame(dicted_rows)).mark_circle(size=90)" is "Chart"
  c:\experiment\minalt.py:11:13 - information: Type of "alt.Chart(pd.DataFrame(dicted_rows)).mark_circle(size=90).encode" is "(angle: str | Angle | dict[Unknown, Unknown] | AngleDatum | AngleValue | UndefinedType = Undefined, color: str | Color | dict[Unknown, Unknown] | ColorDatum | ColorValue | UndefinedType = Undefined, column: str | Column | dict[Unknown, Unknown] | UndefinedType = Undefined, description: str | Description | dict[Unknown, Unknown] | DescriptionValue | UndefinedType = Undefined, detail: str | Detail | dict[Unknown, Unknown] | list[Unknown] | UndefinedType = Undefined, facet: str | Facet | dict[Unknown, Unknown] | UndefinedType = Undefined, fill: str | Fill | dict[Unknown, Unknown] | FillDatum | FillValue | UndefinedType = Undefined, fillOpacity: str | FillOpacity | dict[Unknown, Unknown] | FillOpacityDatum | FillOpacityValue | UndefinedType = Undefined, href: str | Href | dict[Unknown, Unknown] | HrefValue | UndefinedType = Undefined, key: str | Key | dict[Unknown, Unknown] | UndefinedType = Undefined, latitude: str | Latitude | dict[Unknown, Unknown] | LatitudeDatum | UndefinedType = Undefined, latitude2: str | Latitude2 | dict[Unknown, Unknown] | Latitude2Datum | Latitude2Value | UndefinedType = Undefined, longitude: str | Longitude | dict[Unknown, Unknown] | LongitudeDatum | UndefinedType = Undefined, longitude2: str | Longitude2 | dict[Unknown, Unknown] | Longitude2Datum | Longitude2Value | UndefinedType = Undefined, opacity: str | Opacity | dict[Unknown, Unknown] | OpacityDatum | OpacityValue | UndefinedType = Undefined, order: str | Order | dict[Unknown, Unknown] | list[Unknown] | OrderValue | UndefinedType = Undefined, radius: str | Radius | dict[Unknown, Unknown] | RadiusDatum | RadiusValue | UndefinedType = Undefined, radius2: str | Radius2 | dict[Unknown, Unknown] | Radius2Datum | Radius2Value | UndefinedType = Undefined, row: str | Row | dict[Unknown, Unknown] | UndefinedType = Undefined, shape: str | Shape | dict[Unknown, Unknown] | ShapeDatum | ShapeValue | UndefinedType = Undefined, size: str | Size | dict[Unknown, Unknown] | SizeDatum | SizeValue | UndefinedType = Undefined, stroke: str | Stroke | dict[Unknown, Unknown] | StrokeDatum | StrokeValue | UndefinedType = Undefined, strokeDash: str | StrokeDash | dict[Unknown, Unknown] | StrokeDashDatum | StrokeDashValue | UndefinedType = Undefined, strokeOpacity: str | StrokeOpacity | dict[Unknown, Unknown] | StrokeOpacityDatum | StrokeOpacityValue | UndefinedType = Undefined, strokeWidth: str | StrokeWidth | dict[Unknown, Unknown] | StrokeWidthDatum | StrokeWidthValue | UndefinedType = Undefined, text: str | Text | dict[Unknown, Unknown] | TextDatum | TextValue | UndefinedType = Undefined, theta: str | Theta | dict[Unknown, Unknown] | ThetaDatum | ThetaValue | UndefinedType = Undefined, theta2: str | Theta2 | dict[Unknown, Unknown] | Theta2Datum | Theta2Value | UndefinedType = Undefined, tooltip: str | Tooltip | dict[Unknown, Unknown] | list[Unknown] | TooltipValue | UndefinedType = Undefined, url: str | Url | dict[Unknown, Unknown] | UrlValue | UndefinedType = Undefined, x: str | X | dict[Unknown, Unknown] | XDatum | XValue | UndefinedType = Undefined, x2: str | X2 | dict[Unknown, Unknown] | X2Datum | X2Value | UndefinedType = Undefined, xError: str | XError | dict[Unknown, Unknown] | XErrorValue | UndefinedType = Undefined, xError2: str | XError2 | dict[Unknown, Unknown] | XError2Value | UndefinedType = Undefined, xOffset: str | XOffset | dict[Unknown, Unknown] | XOffsetDatum | XOffsetValue | UndefinedType = Undefined, y: str | Y | dict[Unknown, Unknown] | YDatum | YValue | UndefinedType = Undefined, y2: str | Y2 | dict[Unknown, Unknown] | Y2Datum | Y2Value | UndefinedType = Undefined, yError: str | YError | dict[Unknown, Unknown] | YErrorValue | UndefinedType = Undefined, yError2: str | YError2 | dict[Unknown, Unknown] | YError2Value | UndefinedType = Undefined, yOffset: str | YOffset | dict[Unknown, Unknown] | YOffsetDatum | YOffsetValue | UndefinedType = Undefined) -> Chart"
3 errors, 0 warnings, 6 informations

mypy 1.9.0 (compiled: yes), with --strict:

minalt.py:4: error: Call to untyped function "Color" in typed context  [no-untyped-call]
minalt.py:6: note: Revealed type is "def (shorthand: Union[builtins.str, builtins.dict[Any, Any], typing.Sequence[builtins.str], Any, altair.utils.schemapi.UndefinedType] =, aggregate: Union[builtins.dict[Any, Any], Any, Literal['average'], Literal['count'], Literal['distinct'], Literal['max'], Literal['mean'], Literal['median'], Literal['min'], Literal['missing'], Literal['product'], Literal['q1'], Literal['q3'], Literal['ci0'], Literal['ci1'], Literal['stderr'], Literal['stdev'], Literal['stdevp'], Literal['sum'], Literal['valid'], Literal['values'], Literal['variance'], Literal['variancep'], Literal['exponential'], Literal['exponentialb'], altair.utils.schemapi.UndefinedType] =, axis: Union[builtins.dict[Any, Any], None, Any, altair.utils.schemapi.UndefinedType] =, bandPosition: Union[builtins.float, altair.utils.schemapi.UndefinedType] =, bin: Union[builtins.str, builtins.bool, builtins.dict[Any, Any], None, Any, altair.utils.schemapi.UndefinedType] =, field: Union[builtins.str, builtins.dict[Any, Any], Any, altair.utils.schemapi.UndefinedType] =, impute: Union[builtins.dict[Any, Any], None, Any, altair.utils.schemapi.UndefinedType] =, scale: Union[builtins.dict[Any, Any], None, Any, altair.utils.schemapi.UndefinedType] =, sort: Union[builtins.dict[Any, Any], None, typing.Sequence[builtins.str], typing.Sequence[builtins.bool], Any, typing.Sequence[builtins.float], Literal['ascending'], Literal['descending'], typing.Sequence[Union[builtins.dict[Any, Any], Any]], Literal['x'], Literal['y'], Literal['color'], Literal['fill'], Literal['stroke'], Literal['strokeWidth'], Literal['size'], Literal['shape'], Literal['fillOpacity'], Literal['strokeOpacity'], Literal['opacity'], Literal['text'], Literal['-x'], Literal['-y'], Literal['-color'], Literal['-fill'], Literal['-stroke'], Literal['-strokeWidth'], Literal['-size'], Literal['-shape'], Literal['-fillOpacity'], Literal['-strokeOpacity'], Literal['-opacity'], Literal['-text'], altair.utils.schemapi.UndefinedType] =, stack: Union[builtins.bool, None, Any, Literal['zero'], Literal['center'], Literal['normalize'], altair.utils.schemapi.UndefinedType] =, timeUnit: Union[builtins.dict[Any, Any], Any, Literal['year'], Literal['quarter'], Literal['month'], Literal['week'], Literal['day'], Literal['dayofyear'], Literal['date'], Literal['hours'], Literal['minutes'], Literal['seconds'], Literal['milliseconds'], Literal['utcyear'], Literal['utcquarter'], Literal['utcmonth'], Literal['utcweek'], Literal['utcday'], Literal['utcdayofyear'], Literal['utcdate'], Literal['utchours'], Literal['utcminutes'], Literal['utcseconds'], Literal['utcmilliseconds'], Literal['binnedyear'], Literal['binnedyearquarter'], Literal['binnedyearquartermonth'], Literal['binnedyearmonth'], Literal['binnedyearmonthdate'], Literal['binnedyearmonthdatehours'], Literal['binnedyearmonthdatehoursminutes'], Literal['binnedyearmonthdatehoursminutesseconds'], Literal['binnedyearweek'], Literal['binnedyearweekday'], Literal['binnedyearweekdayhours'], Literal['binnedyearweekdayhoursminutes'], Literal['binnedyearweekdayhoursminutesseconds'], Literal['binnedyeardayofyear'], Literal['binnedutcyear'], Literal['binnedutcyearquarter'], Literal['binnedutcyearquartermonth'], Literal['binnedutcyearmonth'], Literal['binnedutcyearmonthdate'], Literal['binnedutcyearmonthdatehours'], Literal['binnedutcyearmonthdatehoursminutes'], Literal['binnedutcyearmonthdatehoursminutesseconds'], Literal['binnedutcyearweek'], Literal['binnedutcyearweekday'], Literal['binnedutcyearweekdayhours'], Literal['binnedutcyearweekdayhoursminutes'], Literal['binnedutcyearweekdayhoursminutesseconds'], Literal['binnedutcyeardayofyear'], Literal['yearquarter'], Literal['yearquartermonth'], Literal['yearmonth'], Literal['yearmonthdate'], Literal['yearmonthdatehours'], Literal['yearmonthdatehoursminutes'], Literal['yearmonthdatehoursminutesseconds'], Literal['yearweek'], Literal['yearweekday'], Literal['yearweekdayhours'], Literal['yearweekdayhoursminutes'], Literal['yearweekdayhoursminutesseconds'], Literal['yeardayofyear'], Literal['quartermonth'], Literal['monthdate'], Literal['monthdatehours'], Literal['monthdatehoursminutes'], Literal['monthdatehoursminutesseconds'], Literal['weekday'], Literal['weekdayhours'], Literal['weekdayhoursminutes'], Literal['weekdayhoursminutesseconds'], Literal['dayhours'], Literal['dayhoursminutes'], Literal['dayhoursminutesseconds'], Literal['hoursminutes'], Literal['hoursminutesseconds'], Literal['minutesseconds'], Literal['secondsmilliseconds'], Literal['utcyearquarter'], Literal['utcyearquartermonth'], Literal['utcyearmonth'], Literal['utcyearmonthdate'], Literal['utcyearmonthdatehours'], Literal['utcyearmonthdatehoursminutes'], Literal['utcyearmonthdatehoursminutesseconds'], Literal['utcyearweek'], Literal['utcyearweekday'], Literal['utcyearweekdayhours'], Literal['utcyearweekdayhoursminutes'], Literal['utcyearweekdayhoursminutesseconds'], Literal['utcyeardayofyear'], Literal['utcquartermonth'], Literal['utcmonthdate'], Literal['utcmonthdatehours'], Literal['utcmonthdatehoursminutes'], Literal['utcmonthdatehoursminutesseconds'], Literal['utcweekday'], Literal['utcweeksdayhours'], Literal['utcweekdayhoursminutes'], Literal['utcweekdayhoursminutesseconds'], Literal['utcdayhours'], Literal['utcdayhoursminutes'], Literal['utcdayhoursminutesseconds'], Literal['utchoursminutes'], Literal['utchoursminutesseconds'], Literal['utcminutesseconds'], Literal['utcsecondsmilliseconds'], altair.utils.schemapi.UndefinedType] =, title: Union[builtins.str, None, typing.Sequence[builtins.str], Any, altair.utils.schemapi.UndefinedType] =, type: Union[Any, Literal['quantitative'], Literal['ordinal'], Literal['temporal'], Literal['nominal'], altair.utils.schemapi.UndefinedType] =, **kwds: Any) -> altair.vegalite.v5.schema.channels.X"
minalt.py:7: note: Revealed type is "def (shorthand: Union[builtins.str, builtins.dict[Any, Any], typing.Sequence[builtins.str], Any, altair.utils.schemapi.UndefinedType] =, aggregate: Union[builtins.dict[Any, Any], Any, Literal['average'], Literal['count'], Literal['distinct'], Literal['max'], Literal['mean'], Literal['median'], Literal['min'], Literal['missing'], Literal['product'], Literal['q1'], Literal['q3'], Literal['ci0'], Literal['ci1'], Literal['stderr'], Literal['stdev'], Literal['stdevp'], Literal['sum'], Literal['valid'], Literal['values'], Literal['variance'], Literal['variancep'], Literal['exponential'], Literal['exponentialb'], altair.utils.schemapi.UndefinedType] =, axis: Union[builtins.dict[Any, Any], None, Any, altair.utils.schemapi.UndefinedType] =, bandPosition: Union[builtins.float, altair.utils.schemapi.UndefinedType] =, bin: Union[builtins.str, builtins.bool, builtins.dict[Any, Any], None, Any, altair.utils.schemapi.UndefinedType] =, field: Union[builtins.str, builtins.dict[Any, Any], Any, altair.utils.schemapi.UndefinedType] =, impute: Union[builtins.dict[Any, Any], None, Any, altair.utils.schemapi.UndefinedType] =, scale: Union[builtins.dict[Any, Any], None, Any, altair.utils.schemapi.UndefinedType] =, sort: Union[builtins.dict[Any, Any], None, typing.Sequence[builtins.str], typing.Sequence[builtins.bool], Any, typing.Sequence[builtins.float], Literal['ascending'], Literal['descending'], typing.Sequence[Union[builtins.dict[Any, Any], Any]], Literal['x'], Literal['y'], Literal['color'], Literal['fill'], Literal['stroke'], Literal['strokeWidth'], Literal['size'], Literal['shape'], Literal['fillOpacity'], Literal['strokeOpacity'], Literal['opacity'], Literal['text'], Literal['-x'], Literal['-y'], Literal['-color'], Literal['-fill'], Literal['-stroke'], Literal['-strokeWidth'], Literal['-size'], Literal['-shape'], Literal['-fillOpacity'], Literal['-strokeOpacity'], Literal['-opacity'], Literal['-text'], altair.utils.schemapi.UndefinedType] =, stack: Union[builtins.bool, None, Any, Literal['zero'], Literal['center'], Literal['normalize'], altair.utils.schemapi.UndefinedType] =, timeUnit: Union[builtins.dict[Any, Any], Any, Literal['year'], Literal['quarter'], Literal['month'], Literal['week'], Literal['day'], Literal['dayofyear'], Literal['date'], Literal['hours'], Literal['minutes'], Literal['seconds'], Literal['milliseconds'], Literal['utcyear'], Literal['utcquarter'], Literal['utcmonth'], Literal['utcweek'], Literal['utcday'], Literal['utcdayofyear'], Literal['utcdate'], Literal['utchours'], Literal['utcminutes'], Literal['utcseconds'], Literal['utcmilliseconds'], Literal['binnedyear'], Literal['binnedyearquarter'], Literal['binnedyearquartermonth'], Literal['binnedyearmonth'], Literal['binnedyearmonthdate'], Literal['binnedyearmonthdatehours'], Literal['binnedyearmonthdatehoursminutes'], Literal['binnedyearmonthdatehoursminutesseconds'], Literal['binnedyearweek'], Literal['binnedyearweekday'], Literal['binnedyearweekdayhours'], Literal['binnedyearweekdayhoursminutes'], Literal['binnedyearweekdayhoursminutesseconds'], Literal['binnedyeardayofyear'], Literal['binnedutcyear'], Literal['binnedutcyearquarter'], Literal['binnedutcyearquartermonth'], Literal['binnedutcyearmonth'], Literal['binnedutcyearmonthdate'], Literal['binnedutcyearmonthdatehours'], Literal['binnedutcyearmonthdatehoursminutes'], Literal['binnedutcyearmonthdatehoursminutesseconds'], Literal['binnedutcyearweek'], Literal['binnedutcyearweekday'], Literal['binnedutcyearweekdayhours'], Literal['binnedutcyearweekdayhoursminutes'], Literal['binnedutcyearweekdayhoursminutesseconds'], Literal['binnedutcyeardayofyear'], Literal['yearquarter'], Literal['yearquartermonth'], Literal['yearmonth'], Literal['yearmonthdate'], Literal['yearmonthdatehours'], Literal['yearmonthdatehoursminutes'], Literal['yearmonthdatehoursminutesseconds'], Literal['yearweek'], Literal['yearweekday'], Literal['yearweekdayhours'], Literal['yearweekdayhoursminutes'], Literal['yearweekdayhoursminutesseconds'], Literal['yeardayofyear'], Literal['quartermonth'], Literal['monthdate'], Literal['monthdatehours'], Literal['monthdatehoursminutes'], Literal['monthdatehoursminutesseconds'], Literal['weekday'], Literal['weekdayhours'], Literal['weekdayhoursminutes'], Literal['weekdayhoursminutesseconds'], Literal['dayhours'], Literal['dayhoursminutes'], Literal['dayhoursminutesseconds'], Literal['hoursminutes'], Literal['hoursminutesseconds'], Literal['minutesseconds'], Literal['secondsmilliseconds'], Literal['utcyearquarter'], Literal['utcyearquartermonth'], Literal['utcyearmonth'], Literal['utcyearmonthdate'], Literal['utcyearmonthdatehours'], Literal['utcyearmonthdatehoursminutes'], Literal['utcyearmonthdatehoursminutesseconds'], Literal['utcyearweek'], Literal['utcyearweekday'], Literal['utcyearweekdayhours'], Literal['utcyearweekdayhoursminutes'], Literal['utcyearweekdayhoursminutesseconds'], Literal['utcyeardayofyear'], Literal['utcquartermonth'], Literal['utcmonthdate'], Literal['utcmonthdatehours'], Literal['utcmonthdatehoursminutes'], Literal['utcmonthdatehoursminutesseconds'], Literal['utcweekday'], Literal['utcweeksdayhours'], Literal['utcweekdayhoursminutes'], Literal['utcweekdayhoursminutesseconds'], Literal['utcdayhours'], Literal['utcdayhoursminutes'], Literal['utcdayhoursminutesseconds'], Literal['utchoursminutes'], Literal['utchoursminutesseconds'], Literal['utcminutesseconds'], Literal['utcsecondsmilliseconds'], altair.utils.schemapi.UndefinedType] =, title: Union[builtins.str, None, typing.Sequence[builtins.str], Any, altair.utils.schemapi.UndefinedType] =, type: Union[Any, Literal['quantitative'], Literal['ordinal'], Literal['temporal'], Literal['nominal'], altair.utils.schemapi.UndefinedType] =, **kwds: Any) -> altair.vegalite.v5.schema.channels.Y"
minalt.py:8: note: Revealed type is "def (*args: Any, **kwds: Any) -> altair.vegalite.v5.schema.core.Color"
minalt.py:9: note: Revealed type is "def (data: Union[Union[builtins.dict[Any, Any], pandas.core.frame.DataFrame, altair.utils.data.SupportsGeoInterface, altair.utils.core.DataFrameLike, altair.vegalite.v5.schema.core.Data, builtins.str, altair.vegalite.v5.schema.core.Generator, Any], Any] =, encoding: Union[altair.vegalite.v5.schema.core.FacetedEncoding, Any] =, mark: Union[builtins.str, altair.vegalite.v5.schema.core.AnyMark, Any] =, width: Union[builtins.int, builtins.str, builtins.dict[Any, Any], altair.vegalite.v5.schema.core.Step, Any] =, height: Union[builtins.int, builtins.str, builtins.dict[Any, Any], altair.vegalite.v5.schema.core.Step, Any] =, **kwargs: Any) -> altair.vegalite.v5.api.Chart"
minalt.py:10: note: Revealed type is "altair.vegalite.v5.api.Chart"
minalt.py:11: note: Revealed type is "Any"
Found 1 error in 1 file (checked 1 source file)

pytype 2024.04.11
(this passes the typechecker with no complaints, so here are just the reveal_type messages)

File "/mnt/c/experiment/minalt.py", line 6, in <module>: Any [reveal-type]
File "/mnt/c/experiment/minalt.py", line 7, in <module>: Any [reveal-type]
File "/mnt/c/experiment/minalt.py", line 8, in <module>: Any [reveal-type]
File "/mnt/c/experiment/minalt.py", line 9, in <module>: Any [reveal-type]
File "/mnt/c/experiment/minalt.py", line 10, in <module>: Any [reveal-type]
File "/mnt/c/experiment/minalt.py", line 11, in <module>: Any [reveal-type]

@binste
Copy link
Contributor

binste commented May 2, 2024

Thanks! Those outputs were very helpful. I think mypy at least thinks that alt.Color is alt.vegalite.v5.schema.core.Color instead of alt.vegalite.v5.schema.channels.Color due to the from * imports in https://github.com/vega/altair/blob/main/altair/vegalite/v5/schema/__init__.py#L4 where the channels overwrite core. We should probably be explicit with the imports (needs to be autogenerated) or specify it in __all__ on core.py.

Is this blocking you from using Altair or can you type: ignore it for now? Just so I know how to prioritise this.

@wyattscarpenter
Copy link
Author

Not a blocker for me at all! As you say, I can just type ignore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants