Conversation
1b4a996 to
07f7cb9
Compare
There was a problem hiding this comment.
@alec-bike there are 2 PRs here
Pyright
Also, the experimental
tool.pyrightsection has been simplified (and tested againstpyrightandbasedpyright).
Could you set up pyright to run in CI first, before making changes like this please?
I was working towards that a while back, but there's nothing verifying your claims.
Locally, pyright is complaining about things that are invisible to a reviewer:
Ruff
I don't see any value in removing C901 comments.
Refactoring the functions is a good way to learn about how altair works or just simplify things for future readers 🙂
07f7cb9 to
fc7c6ff
Compare
|
Thanks for the review @dangotbanned.
I've been wondering about the status of pyright (and multiple type checkers) in altair. Is the goal for altair to support both mypy and pyright in CI? I've been running ty for my testing, using a local |
0bac43d to
c32f652
Compare
0d679f9 to
41687d0
Compare
I guess this is a history of the progress I made with Before that, there was a long road to supporting This section of the config was where there were still gaps, but IIRC some test modules were an issue as well: Lines 374 to 378 in 356c78b
I'm very much looking forward to using Using Running |
dangotbanned
left a comment
There was a problem hiding this comment.
Thanks for the changes @alec-bike
I do still have a few more questions though
altair/vegalite/v6/api.py
Outdated
| """ | ||
| context = context or {} | ||
| kwds: Map = { | ||
| kwds: dict = { |
There was a problem hiding this comment.
| kwds: dict = { | |
| kwds: Map = { |
That alias expands to a type that actually supports **kwds
altair/altair/vegalite/v6/schema/_typing.py
Line 224 in 356c78b
from __future__ import annotations
from typing import Any
def unpack(**kwargs: Any) -> dict[str, Any]:
return kwargs
def any_dict(kwds: dict) -> dict[str, Any]:
return unpack(**kwds)
def safe_dict(kwds: dict[str, Any]) -> dict[str, Any]:
return unpack(**kwds)
any_dict({"keyword": "argument"})
any_dict({1: "boom"})
safe_dict({"keyword": "argument"})
safe_dict({1: "boom"})
# Argument of type "dict[int, str]" cannot be assigned to parameter "kwds" of type
# "dict[str, Any]" in function "safe_dict"
# "Literal[1]" is not assignable to "str"Traceback (most recent call last):
File "../t.py", line 19, in <module>
any_dict({1: "boom"})
~~~~~~~~^^^^^^^^^^^^^
File "../t", line 11, in any_dict
return unpack(**kwds)
TypeError: keywords must be stringsThere was a problem hiding this comment.
Interesting. ty flagged kwds: Map as invalid-argument-type whereas kwds: dict fixed the ty warning. I've reverted this for now and will check with the ty devs.
| context["top_level"] = False | ||
|
|
||
| vegalite_spec = _top_schema_base(super(TopLevelMixin, copy)).to_dict( | ||
| vegalite_spec: Any = _top_schema_base(super(TopLevelMixin, copy)).to_dict( |
There was a problem hiding this comment.
The Any is a result of the change made on _top_schema_base
| vegalite_spec: Any = _top_schema_base(super(TopLevelMixin, copy)).to_dict( | |
| vegalite_spec = _top_schema_base(super(TopLevelMixin, copy)).to_dict( |
There was a problem hiding this comment.
I added this today to revert a change I'd made in commit a2afad3. That commit fixed a ty issue but introduced a pyright error.
I also reverted line 460 back to nm: Any.
With these changes, I no longer see pyright errors on those lines.
# Conflicts: # pyproject.toml
212841c to
e84ddc9
Compare

This PR tidies up some ruff rules and comments in
pyproject.toml:increase max-complexity to 15 (allows removal of somerevertednoqa: C901annotations)Also, the experimental
tool.pyrightsection has been simplified (and tested against pyright and basedpyright).Footnotes
ruff preview was turned off in fix: type issues with Chart mark methods. #3936 ↩