-
Notifications
You must be signed in to change notification settings - Fork 10
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
Implement codemod registry #47
Conversation
d7c5ee3
to
4ef3d63
Compare
Codecov Report
@@ Coverage Diff @@
## main #47 +/- ##
==========================================
+ Coverage 95.82% 95.86% +0.04%
==========================================
Files 38 39 +1
Lines 1413 1476 +63
==========================================
+ Hits 1354 1415 +61
- Misses 59 61 +2
|
4ef3d63
to
a72983a
Compare
a72983a
to
5afd594
Compare
src/codemodder/registry.py
Outdated
codemods: list | ||
|
||
|
||
class _CodemodContainer: |
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.
This is a slightly awkward construct but I might suggest that in the longer time this actually outlines the API we want for the BaseCodemod
class. Eventually maybe this becomes an ABC that all codemods inherit.
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.
Both CodemodCollection and CodemodContainer sound to me like containers of some sort, such as a list. What about making one of these inherit from list? Maybe that's a later thing, just a thought.
Also, how about renaming _CodemodContainer
to CodemodMetadata
or CodemodWrapper
? Also I think this class in particular could be a dataclass. What clues me in to that is all the property methods, but some will have to be manual, of course.
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.
More thoughts, since you have the idea of this class _CodemodContainer
being the "real" BaseCodemod, what do you think is the distinction between the data a BaseCodemod class should store versus this new _CodemodContainer
? I still feel they should be one class but I'm listening!
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.
- I did think about making
CodemodCollection
alist
but I'm not sure whether we really need that API. It might be worth a quick experiment though - I do think maybe
_CodemodWrapper
is a better name and it would be a good dataclass - The main difference between
_CodemodContainer/Wrapper
andBaseCodemod
is that the container knows about the registry and associated metadata and the base codemod does not. But maybe there's a good way to consolidate those two things somehow. I think that's a future effort though.
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.
I'm liking this a ton., Just left some thoughts around naming to clarify concepts.
src/codemodder/registry.py
Outdated
codemods: list | ||
|
||
|
||
class _CodemodContainer: |
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.
Both CodemodCollection and CodemodContainer sound to me like containers of some sort, such as a list. What about making one of these inherit from list? Maybe that's a later thing, just a thought.
Also, how about renaming _CodemodContainer
to CodemodMetadata
or CodemodWrapper
? Also I think this class in particular could be a dataclass. What clues me in to that is all the property methods, but some will have to be manual, of course.
src/codemodder/registry.py
Outdated
codemods: list | ||
|
||
|
||
class _CodemodContainer: |
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.
More thoughts, since you have the idea of this class _CodemodContainer
being the "real" BaseCodemod, what do you think is the distinction between the data a BaseCodemod class should store versus this new _CodemodContainer
? I still feel they should be one class but I'm listening!
5afd594
to
71c014f
Compare
Overview
Move codemods to
core_codemods
package; implement codemod registryDescription
core_codemods
package and implements a codemod registry__init_subclass__
hooks__init_subclass__
validation for the "base" API but some additional work will be required before we can get rid of this in the "sugar" API