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

Refactor stix2.parsing into more focused modules #481

Merged
merged 5 commits into from
Jan 20, 2021

Conversation

chisholm
Copy link
Contributor

Refactor stix2.parsing into more focused modules:

  • stix2.registry, which contains the class mapping structure and code for scanning stix2 modules for its initial population
  • stix2.registration, which contains code used to register custom STIX types with the registry
  • stix2.parsing, which contains code for creating instances of registered stix2 classes from raw dicts

The motivation for this is to reduce the chances of circular import problems. The changes make it possible to import smaller modules with fewer dependencies. The changes could be backward-incompatible though, as it moves APIs around a bit.

chisholm and others added 5 commits January 8, 2021 22:08
- stix2.registry, which contains the class mapping structure
  and code for scanning stix2 modules for its initial population
- stix2.registration, which contains code used to register custom
  STIX types with the registry
- stix2.parsing, which contains code for creating instances of
  registered stix2 classes from raw dicts.

This is intended to reduce circular import problems, by giving
dependent code the ability to import a module which has exactly
the functionality it needs, without pulling a lot of other stuff
it doesn't need.  Fewer imports means less chance of an import
cycle.
top-level stix2 package to stix2.version but import it into
stix2.  This makes it possible for someone to get the symbol
without needing to import all of stix2.

Change an "import X" style import to "from X import Y" in
stix2/__init__.py to be consistent with the other imports in
that file.
@codecov-io
Copy link

codecov-io commented Jan 15, 2021

Codecov Report

Merging #481 (a0d5353) into master (9ed6269) will decrease coverage by 0.04%.
The diff coverage is 64.60%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #481      +/-   ##
==========================================
- Coverage   89.32%   89.27%   -0.05%     
==========================================
  Files         144      146       +2     
  Lines       16020    16032      +12     
==========================================
+ Hits        14310    14313       +3     
- Misses       1710     1719       +9     
Impacted Files Coverage Δ
stix2/__init__.py 0.00% <0.00%> (ø)
stix2/custom.py 84.21% <0.00%> (ø)
stix2/pattern_visitor.py 68.50% <0.00%> (ø)
stix2/properties.py 74.40% <0.00%> (-0.20%) ⬇️
stix2/registry.py 0.00% <0.00%> (ø)
stix2/version.py 0.00% <0.00%> (ø)
stix2/equivalence/pattern/__init__.py 74.28% <40.00%> (ø)
stix2/parsing.py 84.31% <50.00%> (+8.98%) ⬆️
stix2/versioning.py 80.80% <50.00%> (-0.83%) ⬇️
stix2/registration.py 82.02% <82.02%> (ø)
... and 7 more

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 9ed6269...a0d5353. Read the comment docs.

@clenk clenk merged commit 03b3423 into oasis-open:master Jan 20, 2021
@chisholm chisholm deleted the parsing_refactoring branch January 20, 2021 21:56
@emmanvg emmanvg added this to the 3.0.0 milestone Jan 22, 2021
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.

4 participants