-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
add encodings.ascii and encodings.latin_1 #13113
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1139a32
add encodings.ascii and encodings.latin_1
tungol 2f4384e
pyright
tungol db12fbf
use override methods instead of directly assigning the function.
tungol 4b47e75
remove unneeded ignores
tungol 5a23a3b
Merge branch 'main' into encodings_ascii
tungol 2e15472
Merge branch 'main' into encodings_ascii
JelleZijlstra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import codecs | ||
from _typeshed import ReadableBuffer | ||
|
||
class Codec(codecs.Codec): | ||
# At runtime, this is codecs.ascii_encode | ||
@staticmethod | ||
def encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ... | ||
# At runtime, this is codecs.ascii_decode | ||
@staticmethod | ||
def decode(data: ReadableBuffer, errors: str | None = None, /) -> tuple[str, int]: ... | ||
|
||
class IncrementalEncoder(codecs.IncrementalEncoder): | ||
def encode(self, input: str, final: bool = False) -> bytes: ... | ||
|
||
class IncrementalDecoder(codecs.IncrementalDecoder): | ||
def decode(self, input: ReadableBuffer, final: bool = False) -> str: ... | ||
|
||
class StreamWriter(Codec, codecs.StreamWriter): ... | ||
class StreamReader(Codec, codecs.StreamReader): ... | ||
|
||
# Note: encode being a decode function and decode being an encode function is accurate to runtime. | ||
class StreamConverter(StreamWriter, StreamReader): # type: ignore[misc] # incompatible methods in base classes | ||
# At runtime, this is codecs.ascii_decode | ||
@staticmethod | ||
def encode(data: ReadableBuffer, errors: str | None = None, /) -> tuple[str, int]: ... # type: ignore[override] | ||
# At runtime, this is codecs.ascii_encode | ||
@staticmethod | ||
def decode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ... # type: ignore[override] | ||
|
||
def getregentry() -> codecs.CodecInfo: ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import codecs | ||
from _typeshed import ReadableBuffer | ||
|
||
class Codec(codecs.Codec): | ||
# At runtime, this is codecs.latin_1_encode | ||
@staticmethod | ||
def encode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ... | ||
# At runtime, this is codecs.latin_1_decode | ||
@staticmethod | ||
def decode(data: ReadableBuffer, errors: str | None = None, /) -> tuple[str, int]: ... | ||
|
||
class IncrementalEncoder(codecs.IncrementalEncoder): | ||
def encode(self, input: str, final: bool = False) -> bytes: ... | ||
|
||
class IncrementalDecoder(codecs.IncrementalDecoder): | ||
def decode(self, input: ReadableBuffer, final: bool = False) -> str: ... | ||
|
||
class StreamWriter(Codec, codecs.StreamWriter): ... | ||
class StreamReader(Codec, codecs.StreamReader): ... | ||
|
||
# Note: encode being a decode function and decode being an encode function is accurate to runtime. | ||
class StreamConverter(StreamWriter, StreamReader): # type: ignore[misc] # incompatible methods in base classes | ||
# At runtime, this is codecs.latin_1_decode | ||
@staticmethod | ||
def encode(data: ReadableBuffer, errors: str | None = None, /) -> tuple[str, int]: ... # type: ignore[override] | ||
# At runtime, this is codecs.latin_1_encode | ||
@staticmethod | ||
def decode(str: str, errors: str | None = None, /) -> tuple[bytes, int]: ... # type: ignore[override] | ||
|
||
def getregentry() -> codecs.CodecInfo: ... |
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.
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.
Indeed, is that a bug in the runtime?
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.
Not sure.
StreamConverter
only exists on ascii and latin_1 encodings. Both do this, and there's nothing in the stdlib that makes use of them, so I don't know how they're intended to be used. I wondered the same thing, but I can't rule out that this is intended.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.
They've also been this way for almost 25 years now.
It's possible that no one has ever used these classes for anything.