Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix advanced class completion#932

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
sebastinas merged 1 commit intobpython:mainfromgpotter2:class-cmpl
Oct 21, 2021
Merged

Fix advanced class completion#932

sebastinas merged 1 commit intobpython:mainfromgpotter2:class-cmpl
Oct 21, 2021

Conversation

gpotter2
Copy link
Contributor

@gpotter2gpotter2 commentedOct 21, 2021
edited
Loading

This PR removes a check that always tried to autocomplete a class using its__init__ function.

In fact, theinspect module (used afterwards in

signature=inspect.signature(f)
) does a much better job at finding the arguments that are actually typing a class, which aren't always the ones in__init__. Since at least Python 3.6, it handles__call__,__new__ and__signature__ in addition to__init__, so restricting the signatures to__init__ is actually a downgrade.
Seehttps://github.com/python/cpython/blob/2c56c97f015a7ea81719615ddcf3c745fba5b4f3/Lib/inspect.py#L2284

I'm raising this issue because our CLI requires__signature__ to work, which is the case if you letinspect.signature do its job by default but not if you manually selectcls.__init__ 🙂

Note: I also doubt that the__new__ check below is useful on modern Python versions, since__new__ is also checked byinspect.signature (therefore byinspection.getfuncprops), but I didn't remove it in this PR.

thomasballinger reacted with hooray emoji
@sebastinas
Copy link
Contributor

Could this change be accompanied with a test case to avoid regressions in the future?

@gpotter2
Copy link
ContributorAuthor

I've added a test.

@gpotter2
Copy link
ContributorAuthor

Just fixed the black issue.

@sebastinassebastinas merged commit126b059 intobpython:mainOct 21, 2021
@thomasballinger
Copy link
Member

Thanks for bringing bpython completion into the (5 years ago?) future!

gpotter2 reacted with laugh emoji

@gpotter2gpotter2 deleted the class-cmpl branchOctober 21, 2021 17:28
@sebastinassebastinas added this to therelease-0.22 milestoneOct 22, 2021
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
release-0.22
Development

Successfully merging this pull request may close these issues.

3 participants
@gpotter2@sebastinas@thomasballinger

[8]ページ先頭

©2009-2025 Movatter.jp