| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
deprecate_privatize_attribute relies on __setname__/setattr behavior which is not conducive to automatically type hinting. Thus I don't really think its worth fretting over trying to get it to do so. The end effect is that you just do: .py file: class Foo:
attr = deprecate_privatize_attribute("3.8")
_attr = "bar".pyi file: class Foo:
attr: str
_attr: str(You can also opt to not type hint the private version, and potentially to omit the public version as well and add it to the ci/mypy_stubtest_allowlist.txt) Essentially you just take the effect of the decorator and represent it in the pyi This is one of the things that would make inlining more type hints more difficult (if we ever do want to go down that route), but also not necessarily a blocker as I'm not too offended by type checking flagging deprecated things. |
Sorry, something went wrong.
The main issue is the assignment; if you type the left-hand side, the right-hand side is the deprecate_privatize_attribute instance. It appears now I can have it derive from Any, but that apparently was only added in 3.11. On the other hand, we've generally avoided typing deprecated thing if they're difficult, so maybe we should just leave out the types on this one. |
Sorry, something went wrong.
|
Hmm, I'm confused why dates.py is now failing, as I thought it didn't have any typing, but I think I've fixed it. |
Sorry, something went wrong.
|
|
||
| @overload | ||
| def rename_parameter( | ||
| since: str, old: str, new: str, func: Literal[None] = None |
There was a problem hiding this comment.
| since: str, old: str, new: str, func: Literal[None] = None | |
| since: str, old: str, new: str, func: None=... |
None, being a singleton, has no need to be called out as Literal[None].
Additionally, pyi files call for the actual value of defaults to be omitted (which admittedly makes little difference when the type hint is None...)
Same applies to all other uses of Literal in this file.
Sorry, something went wrong.
There was a problem hiding this comment.
It's not wrong just a bit out of place/using tools that are not needed for the task at hand
Sorry, something went wrong.
While we don't normally type private API, these are used all over Matplotlib, and it makes sense to type them for internal checking purposes.
| Back | FazBrowse Home | New Git URL |
PR summary
While we don't normally type private API, these are used all over Matplotlib, and it makes sense to type them for internal checking purposes.
I'm uncertain how to actually type hint deprecate_privatize_attribute because it takes on the type of the thing it's wrapping. I tried to do this in test_api.py, but I'm not sure I was successful.
PR checklist