-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix reporting violations on Module nodes (#368)
Currently in fixit v2.0.0.post1 calling self.report() in a Module node visitor like so: ``` def visit_Module(self, node: cst.Module) -> None: self.report(node) ``` resulted in a libcst error where the module node was passed into self.get_metadata like so: ``` self.get_metadata(ParentNodeProvider, node) ``` I am assuing this fails intentionally in libcst because what is the parent of a module? Nothing. It results in this error: ``` python3.10/site-packages/fixit/rule.py:151: in node_comments parent = self.get_metadata(ParentNodeProvider, node) python3.10/site-packages/libcst/_metadata_dependent.py:136: in get_metadata value = self.metadata[key][node] E KeyError: Module( E body=[ E SimpleStatem -the rest of the error is just the rest of the module tree- ``` This PR aims to fix that by yielding any comments that exist in a module's header(which is the current intention of fixit) and if the current visitor is not a module node it will check its parent with the ParentNodeProvider like it already does.
- Loading branch information
Showing
2 changed files
with
95 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters