Skip to content
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

Support bound methods in stubs #761

Closed
hauntsaninja opened this issue Dec 14, 2020 · 2 comments
Closed

Support bound methods in stubs #761

hauntsaninja opened this issue Dec 14, 2020 · 2 comments
Assignees
Labels
cat: stubs and 3p type stubs and third-party types enhancement

Comments

@hauntsaninja
Copy link
Contributor

For instance,

class WorkingSet:
    def require(self, *requirements: _NestedStr) -> Sequence[Distribution]: ...

working_set: WorkingSet
require = working_set.require

This is something mypy supports and has come up a couple times in typeshed, since it reduces redundancy / allows changes to be made in only one place. e.g. python/typeshed#4817, https://github.com/python/typeshed/blob/ac234f25927634e06d9c96df98d72d54dd80dfc4/stdlib/2and3/turtle.pyi#L284-L291 and python/typeshed#4282 (comment)

@rchen152
Copy link
Contributor

Hmm, aliasing to a method of an instance of a class in the same file is relatively straightforward; I can probably get that done sometime this week. It gets trickier when the class is in another file, as we don't currently have a way of representing that.

rchen152 added a commit that referenced this issue Dec 16, 2020
@rchen152 rchen152 added the cat: stubs and 3p type stubs and third-party types label Jan 19, 2021
@hauntsaninja
Copy link
Contributor Author

Thanks for fixing this! Are you planning on adding support for bound methods when the class is in another file? (This came up again in a change to multiprocessing stubs python/typeshed#5231)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cat: stubs and 3p type stubs and third-party types enhancement
Projects
None yet
Development

No branches or pull requests

2 participants