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
I understand that adding another dependency just to reduce 5 lines of code is probably not worth it. I also agree that there may be other recent type-related changes in the core of Python that makes it something to consider if we look a bit broader than this PR alone.
We previously had two types of discussions about types in Altair.
One is about improving the existing Python code in the /tools folder in the Altair repository, such as this issue (Type hints #2493) and related PR (Add type hints to tools.schemapi.schemapi #2614, btw I now notice that this PR also uses the TypeVar bound approach).
Especially the result of the second bullet has set the type Any to anything that is Undefined finishing this discussion on, 'what is the type of Undefined?'.
However, with your impressive PRs regarding jsonschema and types, I was wondering, since types are included in the vega-lite jsonschema, if these types can also be inferred for each argument? Maybe recent type-related changes in the core of Python can make this easier? It is merely an open question from which I don't know enough if it is worthwhile to consider.
There are probably also synergies with replacing the vega-lite types with Python types in all error messages (suggested by you in #2842 (comment)) and docstrings.
As more type hints shouldn't break anyones code, I don't think we would need to necessarily include it in the release candidate but I'm definitely intrigued in giving this a try. I really like the development experience you get for a library with well-defined type hints such as better autocompletion as well as early warnings if you pass a wrong value to an argument before even executing the code, for example if you'd pass an integer to stack. The same linters could then of course be used in CI/CD pipelines.
I'll try to get a draft PR going in the coming weeks so we can further explore how well it works.
The text was updated successfully, but these errors were encountered:
Type checking from the jsonschema is interesting, but it is likely that the flexibility of python does not always match with the schema. See e.g. #2877
Based on these two comments in this PR #2846:
and
The text was updated successfully, but these errors were encountered: