-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
Updated "What's New" with my recent commits. #25771
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
Updated "What's New" with my recent commits. #25771
Conversation
|
Pablo: I tagged you because I made two edits not in my section. ISTM the document was using "annotations" where it meant "type hints" in a couple places. Do you agree, or should I back out of those changes? |
Fidget-Spinner
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Larry, thanks for the patch. When I wrote the sections on type hints, I was using type annotations and hints interchangeably. I forgot that there are subtle differences between the two. Most of the changes LGTM. Thanks for making them!
Doc/whatsnew/3.10.rst
Outdated
| stringized annotations. :func:`inspect.get_annotations` is now considered | ||
| best practice for accessing the annotations dict defined on any Python object. | ||
| Relatedly, :func:`inspect.signature`, | ||
| :func:`inspect.from_callable`, and `inspect.from_function` now call |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests are failing due to this line:
| :func:`inspect.from_callable`, and `inspect.from_function` now call | |
| :func:`inspect.from_callable`, and :func:`inspect.from_function` now call |
alternatively you can just use double backticks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a big fan of :func: these days, definitely going that way with it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And, maybe I've been thinking about this topic way too long, but I don't think the difference is subtle ;-)
Think of it this way: an annotation is defined by a syntactic context, a type hint is defined as something inheriting from TypeVar (or its stringized equivalent, etc etc). It's true that lots of people only ever use type hints as annotations, and only ever annotate with type hints. But they're still very different concepts--confusing the two is like confusing a function argument and an int.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I agree with what you said - type hints need not be annotations, it just needs to bear some meaning to the type checker (eg. type comments). Whilst annotations is a purely syntactical construct (well bar some exceptions like in dataclasses and runtime checking)
I only noticed the major difference while I was writing another comment and reflecting for the 10 seconds after posting 😉 . Hence why I promptly deleted that comment after feeling pretty dumb hehe.
PS. regarding `
a type hint is defined as something inheriting from TypeVar
Where can I read more about this? I didn't know and I can't find much info about that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I misspoke. There are a couple other things that can be type hints. Types, for example :D
I'm not an expert on typing or type hints. All I can really tell you is that typing._type_check() appears to be as canonical a source as one is likely to find. It smiles upon instances of type, Any, NoReturn, TypeVar, ForwardRef, Union, ParamSpec, and some instances of _GenericAlias. It complains about instances of _SpecialForm, the objects Generic and Protocol, or any callable not previously explicitly permitted. And anything I didn't mention above seems to get a pass, too.
|
I fixed the bugs Fidget-Spinner pointed out (I think?), and made a couple more clarifications / edits to What's New In Python 3.10. I wonder why I don't see the test failures on my machine-- |
The checks also run Here's a copy of the command the bot runs: So I think if you run |
Fidget-Spinner
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
|
@larryhastings: Please replace |
|
Thanks for the review and the feedback! |
No description provided.