-
-
Notifications
You must be signed in to change notification settings - Fork 2.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
Remove all builtins.unicode
references
#13272
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
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
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
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 |
---|---|---|
|
@@ -401,12 +401,6 @@ def get_default_arg_types(self, fdef: FuncDef) -> List[Optional[Type]]: | |
for arg in fdef.arguments | ||
] | ||
|
||
def add_adjustments(self, typs: List[Type]) -> List[Type]: | ||
if not self.try_text or self.manager.options.python_version[0] != 2: | ||
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. It looks like whole |
||
return typs | ||
translator = StrToText(self.named_type) | ||
return dedup(typs + [tp.accept(translator) for tp in typs]) | ||
|
||
def get_guesses( | ||
self, | ||
is_method: bool, | ||
|
@@ -420,7 +414,6 @@ def get_guesses( | |
This focuses just on the argument types, and doesn't change the provided return type. | ||
""" | ||
options = self.get_args(is_method, base, defaults, callsites, uses) | ||
options = [self.add_adjustments(tps) for tps in options] | ||
|
||
# Take the first `max_guesses` guesses. | ||
product = itertools.islice(itertools.product(*options), 0, self.max_guesses) | ||
|
@@ -909,23 +902,6 @@ def visit_callable_type(self, t: CallableType) -> str: | |
return f"Callable[{arg_str}, {t.ret_type.accept(self)}]" | ||
|
||
|
||
class StrToText(TypeTranslator): | ||
def __init__(self, named_type: Callable[[str], Instance]) -> None: | ||
self.text_type = named_type("builtins.unicode") | ||
|
||
def visit_type_alias_type(self, t: TypeAliasType) -> Type: | ||
exp_t = get_proper_type(t) | ||
if isinstance(exp_t, Instance) and exp_t.type.fullname == "builtins.str": | ||
return self.text_type | ||
return t.copy_modified(args=[a.accept(self) for a in t.args]) | ||
|
||
def visit_instance(self, t: Instance) -> Type: | ||
if t.type.fullname == "builtins.str": | ||
return self.text_type | ||
else: | ||
return super().visit_instance(t) | ||
|
||
|
||
TType = TypeVar("TType", bound=Type) | ||
|
||
|
||
|
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
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.
This now became unused