-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
gh-126543: Docs: change "bound type var" to "bounded" when used in the context of the 'bound' kw argument to TypeVar #126584
Conversation
The name "evaluate_bound" isn't set in stone; it was added during the 3.14 alphas and does not yet have any compatibility constraints. However, I think it should match the Using "upper bound" instead of "bound" in the documentation seems like a good idea. |
Agreed! |
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 for this!
There. I also changed the two instances of "bound" as noun to "upper bound", as mentioned in the OP. I still feel that the expressions "bounded" and "upper bound" may appear disconnected. Maybe the similarity of the words is enough to imply that the expressions are talking about the same thing, but maybe it's not clear for a reader not used to typing -- I'm really not sure. (Also, maybe it's just that English is not my native language.) Currently, the first time both expressions appear is in the following snippet. Perhaps adding just this small note would be enough? This syntax can also be used to create bounded and constrained type
variables::
class StrSequence[S: str]: # S is a TypeVar with a `str` upper bound
- ...
+ ... # We also say that S is bounded by str
class StrOrBytesSequence[A: (str, bytes)]: # A is a TypeVar constrained to str or bytes
... |
That seems reasonable to me! Or maybe This syntax can also be used to create bounded and constrained type
variables::
- class StrSequence[S: str]: # S is a TypeVar with a `str` upper bound
- ...
+ class StrSequence[S: str]: # S is a TypeVar with a `str` upper bound;
+ ... # we can say that S is "bounded by `str`"
class StrOrBytesSequence[A: (str, bytes)]: # A is a TypeVar constrained to str or bytes
... |
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.
Thank you!
I think I'm happy with it! Do I need to do anything else? Thank you all for the very fast iteration! |
Not from my perspective! I'll wait a little while before merging, though, in case @JelleZijlstra or anybody else has any comments (there was quite a bit of discussion on the issue!) |
Co-authored-by: Jelle Zijlstra <[email protected]>
Oh wow I used GitHub's "accept suggestion" button, and now it created a commit with a different email address. Do I really need to sign the CLA again? Can I force-push changing that to my email address that had already signed the CLA? EDIT: I guess it doesn't hurt to have the CLA signed from multiple addresses. Please tell me if having multiple addresses in the commit list is not desirable for any reason. |
I'm pretty sure that should be fine :-) |
Thanks @fofoni for the PR, and @JelleZijlstra for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13. |
No worries! We squash-merge so it doesn't really matter. |
… in the context of the 'bound' kw argument to TypeVar (pythonGH-126584) (cherry picked from commit 434b297) Co-authored-by: Pedro Fonini <[email protected]>
GH-126657 is a backport of this pull request to the 3.13 branch. |
… in the context of the 'bound' kw argument to TypeVar (pythonGH-126584) (cherry picked from commit 434b297) Co-authored-by: Pedro Fonini <[email protected]>
GH-126658 is a backport of this pull request to the 3.12 branch. |
…d in the context of the 'bound' kw argument to TypeVar (GH-126584) (#126657) (cherry picked from commit 434b297) Co-authored-by: Pedro Fonini <[email protected]>
…d in the context of the 'bound' kw argument to TypeVar (GH-126584) (#126658) (cherry picked from commit 434b297) Co-authored-by: Pedro Fonini <[email protected]>
I only changed instances of "bound" when they were being used as an adjective. I left other instances as they were:
Of course, instances of bound-as-in-binding were not touched.
The docs for the
TypeVar.__bound__
attribute use the word "bound" as a noun. I thought about changing it to "boundary" or "boundary type", but gave up because there is also aTypeVar.evaluate_bound
method, so "bound" as a noun is kind of set in stone. One other possibility (which I believe would be a positive change) is to change "bound" to "upper bound" here, i.e.:(I think the "bound" inside the versionchanged block is fine, I wouldn't touch it.)
The docs for
ParamSpec
also use "bound" as a noun, like this:I also though about changing it to "... a
TypeVar
bounded by ...", but I don't think it's necessary (though I also don't think it would be a negative change). If we end up changing "bound" to "upper bound" in the item above, then maybe the same should be done here. (But note that the expression "upper bound" does not currently appear in this document.)📚 Documentation preview 📚: https://cpython-previews--126584.org.readthedocs.build/