Skip to content
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

Fix star-imports from stix2.v20 and v21 #404

Merged
merged 1 commit into from
Jun 5, 2020

Conversation

chisholm
Copy link
Contributor

@chisholm chisholm commented Jun 3, 2020

Fixes #399 .

stix2/__init__.py currently does a star-import from stix2.v20. Unfortunately that brings in a "base" symbol which becomes stix2.base, and hides the actual stix2/base.py module. This PR adds __all__s to the v20 and v21 modules which explicitly lists what symbols should be imported, so we don't get "base" by mistake from them.

(Impl note: the text block split() technique makes it easier to keep the __all__ lists up-to-date, because you can just copy-paste the symbol lists from the imports above.)

star-imports from those modules get the right symbols.  "base"
was a problem because it was getting imported via
stix2/__init__.py and overwriting stix2.base, making the actual
stix2/base.py module inaccessible.
@codecov-commenter
Copy link

codecov-commenter commented Jun 3, 2020

Codecov Report

Merging #404 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #404   +/-   ##
=======================================
  Coverage   98.44%   98.44%           
=======================================
  Files         127      127           
  Lines       14634    14636    +2     
=======================================
+ Hits        14406    14408    +2     
  Misses        228      228           
Impacted Files Coverage Δ
stix2/v20/__init__.py 100.00% <100.00%> (ø)
stix2/v21/__init__.py 100.00% <100.00%> (ø)

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 7e41825...7def04f. Read the comment docs.

@clenk
Copy link
Contributor

clenk commented Jun 5, 2020

Thanks @chisholm!

@clenk clenk merged commit 1a46b13 into oasis-open:master Jun 5, 2020
@emmanvg emmanvg added this to the 2.0.0 milestone Jun 5, 2020
@chisholm chisholm deleted the fix_stix2_base_import branch June 5, 2020 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Star import of v20 shadows stix2.base
4 participants