Skip to content

Added fixers to lib2to3 #10003

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

Merged
merged 11 commits into from
Apr 28, 2023
Merged

Conversation

Avasam
Copy link
Collaborator

@Avasam Avasam commented Apr 3, 2023

Did this a while ago and forgot to PR. Wanted to take a look at some of the oldest issues and this one didn't seem too hard.
Closes #2510 , the least recently updated issue in typeshed (as of starting this PR)!

Add all missing stubs in lib2to3. pyright-complete most of it.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@JelleZijlstra
Copy link
Member

Thanks for all the work, but given that this is a lot of new stubs and lib2to3 is deprecated (to be removed in 3.13), I'm not sure we should really be adding all this.

@github-actions

This comment has been minimized.

@Avasam
Copy link
Collaborator Author

Avasam commented Apr 26, 2023

Up to you! There's still a while before 3.13. Most of the changes came from stubgen and some search&replace.

@srittau
Copy link
Collaborator

srittau commented Apr 27, 2023

Personally, I'm fine with adding this, although we could do a superficial review for the newly added files.

@JelleZijlstra
Copy link
Member

Yes, I suppose there's no harm in it. I will take a quick look and merge this.

def run(self, leaves: Iterable[Leaf]) -> defaultdict[BaseFix, list[Node | Leaf]]: ...
def print_ac(self) -> None: ...

def type_repr(type_num: _T) -> _T: ...
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def type_repr(type_num: _T) -> _T: ...
def type_repr(type_num: int) -> str | int: ...

It takes the number of a parse tree node and returns either its name or the number again if it isn't found.


class FixFuture(fixer_base.BaseFix):
BM_compatible: ClassVar[Literal[True]]
PATTERN: ClassVar[LiteralString]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think LiteralString makes much sense in cases like this. Let's avoid using it.

@Avasam Avasam requested a review from JelleZijlstra April 28, 2023 03:57
@github-actions
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@JelleZijlstra JelleZijlstra merged commit fb4bf03 into python:main Apr 28, 2023
@Avasam Avasam deleted the lib2to3-fixer_base-and-main branch April 29, 2023 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lib2to3 stubs are incomplete
3 participants