-
Notifications
You must be signed in to change notification settings - Fork 49
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
Standalone contract #222
base: master
Are you sure you want to change the base?
Standalone contract #222
Conversation
Ha ha, thanks so much for all your work! It will take me a few days to go through everything, but excited to see what you've done. |
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.
Nice work - this is nearly there.
Most of the comments are fairly minor / trivial, let me know if any questions.
Would you mind adding something to the CHANGELOG
and your name to AUTHORS.rst
?
|
||
**Configuration options** | ||
|
||
- ``modules``: A list of modules/subpackages that should be independent of each other. |
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.
This line needs to be updated as it's from the independence contract.
modules = | ||
mypackage.bar | ||
mypackage.baz | ||
ignore_imports = |
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.
I think it would be better to remove the ignore_imports
section from the example, just so it's minimal.
**Configuration options** | ||
|
||
- ``modules``: A list of modules/subpackages that should be independent of each other. | ||
- ``ignore_imports``: See :ref:`Shared options`. |
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.
We should also add unmatched_ignore_imports_alerting
as an option.
|
||
type_name = "standalone" | ||
|
||
modules = fields.ListField(subfield=fields.ModuleField()) |
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.
Any reason not to make this a SetField
? Order isn't important...
output.print_error(f"- {downstream} is not allowed to import {upstream}") | ||
output.new_line() | ||
|
||
def _check_all_modules_exist_in_graph(self, graph: ImportGraph) -> None: |
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.
Now that this is used by two contracts, would you mind moving this to contract_utils
?
|
||
assert contract_check.kept, contract_check.metadata | ||
|
||
def test_non_standalone_imported(self): |
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.
Mind adding a test case for multiple importeds and importers to/from multiple modules, just to check the logic of handling multiple violations?
@@ -27,6 +27,9 @@ def __init__(self, name: str) -> None: | |||
""" | |||
self.name = name | |||
|
|||
def has_wildcard_expression(self) -> bool: |
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.
I don't think this commit belongs in this PR, correct?
It would be interesting to support module expressions in standalone contracts, but perhaps that's left for another day!
@@ -0,0 +1,162 @@ | |||
from __future__ import annotations |
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.
Nice tests, thanks!
session_options={"root_packages": ["mypackage"]}, | ||
contract_options={ | ||
"modules": ("mypackage.green", "mypackage.yellow"), | ||
"ignore_imports": ["mypackage.yellow -> mypackage.other"], |
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.
Very minor comment, but we could allow passing in the ignore_imports
as an optional argument to the utility method.
|
||
- mypackage.green.b.a is not allowed to import mypackage.green.a.b | ||
|
||
""" # noqa |
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.
Why the noqa
?
Closes #181
(Ending the PR streak here - hope we can merge them after some review and get another release out)