Skip to content

Added fixers to lib2to3 - #10003

Merged
JelleZijlstra merged 11 commits into
python:mainfrom
Avasam:lib2to3-fixer_base-and-main
Apr 28, 2023
Merged

JelleZijlstra merged 11 commits into
python:mainfrom
Avasam:lib2to3-fixer_base-and-main

Conversation

@Avasam

@Avasam Avasam commented Apr 3, 2023 •

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
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

Avasam commented Apr 26, 2023 •

Copy link
Copy Markdown
Collaborator Author

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

@srittau

srittau commented Apr 27, 2023

Copy link
Copy Markdown
Collaborator

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

@JelleZijlstra

Copy link
Copy Markdown
Member

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

Comment thread stdlib/lib2to3/btm_matcher.pyi Outdated
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
Copy Markdown
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.

Comment thread stdlib/lib2to3/fixes/fix_future.pyi Outdated

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

Copy link
Copy Markdown
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
Copy Markdown
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