-
-
Notifications
You must be signed in to change notification settings - Fork 280
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
Add annotations for ModuleType
#1525
Conversation
Pull Request Test Coverage Report for Build 2210064454
💛 - Coveralls |
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.
LGTM, nice cleanup, and also performance improvement because named tuple using exec are slow. I think we were using module_type instead of type because type is a builtin and pylint is raising a warning for this.
|
||
_ModuleSpec = collections.namedtuple( | ||
"_ModuleSpec", "name type location " "origin submodule_search_locations" |
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.
There was a useless implicit string concatenation here.
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.
Yeah, could have been to indicate the optional parameter originally, but I'm not certain.
Probably. Unfortunately, that's always a risk when dealing with the name |
Description
Replace
collections.namedtuple
withtyping.NamedTuple
. An issue here is thatModuleType
previously implemented a custom__new__
method which modified one parameter nametype
vsmodule_type
. This PR modifies the constructor parameter name (module_type
). That way all existingModuleSpec
instances can still access thetype
attribute.I've added a changelog entry since technically it's a breaking change. However, I don't think anyone should be impacted by it.
ModuleType
is (almost ?) exclusively used for internal code.