GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — PEP 675: List the `str` methods that preserve literal types by pradeep90 · Pull Request #2282 · python/peps Conversation
Contributor
cc @gbleaney Mostly looking for feedback on the two design choices we need to make:
We are leaning towards 1b and 2a. Let us know your thoughts. We have also offered to change it if the Steering Council feels strongly. Also, I recall that, as a typeshed maintainer, you wanted us to give clear recommendations for future typeshed changes. Could you clarify the questions we need to address? Finally, we'll change the name from
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
JelleZijlstra
requested changes
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd prefer 2a. Documenting the decision in typeshed makes it more discoverable than a set-in-stone list in a PEP that every type checker has to copy. Question 1 is related to my previous query about typeshed. Basically, as a typeshed maintainer I want to know when I should accept a PR that adds For example, if someone wants us to add a Literal[str] overload for https://docs.python.org/3/library/fnmatch.html#fnmatch.translate (random example from
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This feels too low-level for the SC to decide, unless you have concrete indications that it's something they're concerned about. I'd prefer if the PEP takes a concrete stance, otherwise it just becomes something that can drag out the discussion. (I don't want another PEP 646.)
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Makes sense. I'll add the concrete stance we've agreed on and remove this offer.
Too soon, Jelle. Too soon :)
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page. str methods that preserve literal types.str methods that preserve literal types
Member
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Member
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
CAM-Gerlach
requested changes
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix the syntax error causing a build failure and a few other RST syntax issues
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsUh oh!
There was an error while loading. Please reload this page.
Comment on lines
+545
to
+546
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Is there a reason this was reverted? It is simpler and more reliable to use
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @CAM-Gerlach can we add a lint check for this? It could probably look for python.org/dev/peps with a whitelist of ones we don't want to change [yet] (a few in 1,12,287 from memory). A
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Huh. The official PEP page renders the
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Good idea; in work. If/when PEP 676 is accepted and we transition to the Sphinx-based infra, we could also add one for hardcoded links to PEP supplementary files, instead of using
The GitHub Markdown preview only has very limited compatibility with RST syntax and should never be relied upon; we will have rendered previews on PRs soon assuming PEP 676 is accepted (or possibly before, depending on when @AA-Turner adds it). Until then, please follow the instructions in the Readme/Contributing guide (basically, install the
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page.
Member
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Contributor
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Member
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. These methods will need to have an overload for the `Literal[str]` type.
pradeep90
force-pushed
the
literal-strings
branch
from
1564365 to
d7bece6
Compare
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! Noticed one typo, I'll push the fix
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsUh oh!
There was an error while loading. Please reload this page.
CAM-Gerlach
approved these changes
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LGTM, thanks @pradeep90!
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
8 tasks done
Contributor
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
JelleZijlstra
approved these changes
3 tasks done
cdce8p
reviewed
Comment on lines
+969
to
+973
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't know if that's the right place for it to ask. Instead of overloads, wouldn't it also work / be better to use a bound TypeVar or the new From the PEP: Rationale [...] LiteralString is the "supertype" of all literal string types. In effect, this PEP just introduces a type in the type hierarchy between Literal["foo"] and str. [...]
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A >>> class Foo(str): ... ... >>> Foo('hi') 'hi' >>> type(_) <class '__main__.Foo'> >>> Foo('hi').capitalize() 'Hi' >>> type(_) <class 'str'>
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think a TypeVar with constraints (similar to AnyStr) might work?
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm — that might work, but might also run into mypy bugs similar to python/typeshed#6762?
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
@cdce8p You could also bring it up on the official typing-sig thread for this PEP, which appears to be this one—that might be more generally visible than a comment on a merged PR, if you're looking for a wider discussion. On a more editorial note, it looks like the PEP hasn't yet been updated with the link to the actual discussion thread, which I only found after a fair amount of determined digging (and guessing). I'll open a PR to add that.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Reviewers+1 more reviewerUh oh!
There was an error while loading. Please reload this page. AssigneesNo one assignedLabelsProjectsMilestoneNo milestoneDevelopmentSuccessfully merging this pull request may close these issues. Uh oh!
There was an error while loading. Please reload this page. Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later. | ||||||||||||||||||||||||||||||||||||||||||||||
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |