-
-
Notifications
You must be signed in to change notification settings - Fork 7
Fix & test for import from *.conftest #18
Fix & test for import from *.conftest #18
Conversation
Codecov Report
@@ Coverage Diff @@
## main #18 +/- ##
==========================================
+ Coverage 85.29% 85.58% +0.29%
==========================================
Files 26 26
Lines 340 340
==========================================
+ Hits 290 291 +1
+ Misses 50 49 -1
Continue to review full report at Codecov.
|
@@ -12,7 +12,7 @@ def visit_ImportFrom( | |||
node: ast.ImportFrom, | |||
parent: ast.AST, | |||
) -> Iterator[Tuple[int, int, str]]: | |||
if node.module == "conftest": | |||
if isinstance(node.module, str) and "conftest" in node.module: |
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.
Cool, thanks for fixing and adding a test! Would it work to, instead, check if conftest
is in state.from_imports['pandas']
?
EDIT
nevermind, maybe not - I'll check this tomorrow, but thanks for your PR!
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.
ooo let me check! sorry i didnt know how "fuzzy" the match should be
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.
actually, couldn't resist to check it now :)
I presume you did the isinstance
check to satisfy the mypy
check? If so, I think we just need to check it's not None
. And the second part, I think I'd split on '.'
and check the last element, so something like:
if node.module is not None and node.module.split('.')[-1] == 'conftest':
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.
yes i did heh. oooo nice, looks like that works 🎊
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.
updated!
…not use in operator
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.
Awesome, thank you so much @mgmanzella !
Change to
visit_ImportFrom
in conftest.py to check if module contains "conftest" at the end