Skip to content
This repository was archived by the owner on Feb 19, 2023. It is now read-only.

Fix & test for import from *.conftest #18

Merged
merged 2 commits into from
Apr 10, 2021

Conversation

mgmanzella
Copy link
Contributor

@mgmanzella mgmanzella commented Apr 10, 2021

Change to visit_ImportFrom in conftest.py to check if module contains "conftest" at the end

@codecov
Copy link

codecov bot commented Apr 10, 2021

Codecov Report

Merging #18 (a38925d) into main (0808097) will increase coverage by 0.29%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            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     
Impacted Files Coverage Δ
pandas_dev_flaker/_plugins_tree/conftest.py 100.00% <100.00%> (ø)
pandas_dev_flaker/_plugins_tree/namespace_usage.py 100.00% <0.00%> (+12.50%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0808097...a38925d. Read the comment docs.

@@ -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:
Copy link
Member

@MarcoGorelli MarcoGorelli Apr 10, 2021

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!

Copy link
Contributor Author

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

Copy link
Member

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':

Copy link
Contributor Author

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 🎊

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated!

@MarcoGorelli MarcoGorelli self-requested a review April 10, 2021 17:12
Copy link
Member

@MarcoGorelli MarcoGorelli left a 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 !

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants