-
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
Add as_packages to Forbidden contracts #229
base: master
Are you sure you want to change the base?
Add as_packages to Forbidden contracts #229
Conversation
937046f
to
9227c71
Compare
70ff3b4
to
84c664e
Compare
063c8be
to
c2a9d25
Compare
( | ||
False, | ||
( | ||
"mypackage.blue", | ||
"mypackage.green", | ||
"mypackage.yellow", | ||
"mypackage.purple", | ||
), | ||
[ | ||
{ | ||
"upstream_module": "mypackage.green", | ||
"downstream_module": "mypackage.three", | ||
"chains": [ | ||
[ | ||
{ | ||
"importer": "mypackage.three", | ||
"imported": "mypackage.green", | ||
"line_numbers": (4,), | ||
} | ||
] | ||
], | ||
}, | ||
{ | ||
"upstream_module": "mypackage.purple", | ||
"downstream_module": "mypackage.two", | ||
"chains": [ | ||
[ | ||
{ | ||
"importer": "mypackage.two", | ||
"imported": "mypackage.utils", | ||
"line_numbers": (9,), | ||
}, | ||
{ | ||
"importer": "mypackage.utils", | ||
"imported": "mypackage.purple", | ||
"line_numbers": (1,), | ||
}, | ||
] | ||
], | ||
}, | ||
], | ||
), | ||
], | ||
) |
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 is a new test case
@pytest.mark.parametrize( | ||
"as_packages", | ||
( | ||
("False"), |
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.
🍷 New test case
def test_is_broken_when_forbidden_external_modules_imported(self): | ||
@pytest.mark.parametrize( | ||
"as_packages", | ||
(False, True), |
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.
🍷 False is a new test case
@pytest.mark.parametrize( | ||
"as_packages", | ||
( | ||
("False"), |
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.
🍷 New test case
@pytest.mark.parametrize( | ||
"as_packages", | ||
( | ||
("False"), |
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.
🍷 New test case
False, | ||
("mypackage.green",), | ||
[ | ||
{ | ||
"upstream_module": "mypackage.green", | ||
"downstream_module": "mypackage.three", | ||
"chains": [ | ||
[ | ||
{ | ||
"importer": "mypackage.three", | ||
"imported": "mypackage.green", | ||
"line_numbers": (4,), | ||
}, | ||
] | ||
], | ||
}, | ||
], | ||
), |
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.
🍷 New test case
def test_ignore_imports_with_recursive_wildcards(self): | ||
@pytest.mark.parametrize( | ||
"as_packages", | ||
(False, True), |
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.
🍷 False is a new test case
@pytest.mark.parametrize( | ||
"as_packages", | ||
( | ||
("False"), |
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.
🍷 New test case
@pytest.mark.parametrize( | ||
"as_packages", | ||
( | ||
("False"), |
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.
🍷 New test case
* Fabian Binz - https://github.com/fbinz |
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.
Not sure why this has registered as a change 🤔
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.
It's just because there is a line ending added to the end of that line.
c2a9d25
to
d202c51
Compare
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.
Looking great!
I would approve it, but the checks aren't passing. I suspect you'll need to put # type:ignore
comments on those - contract fields don't play well with mypy.
Nothing else is blocking. If you felt like adding public facing docs then that would be appreciated, but I can also do it in a follow up if you prefer.
* Fabian Binz - https://github.com/fbinz |
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.
It's just because there is a line ending added to the end of that line.
d202c51
to
8165aaa
Compare
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.
The tests are still failing - are you able to run tox -echeck
locally to see if you can reproduce?
754e08d
to
a3b20e3
Compare
Implement the funcitonality for treating the forbidden modules as a module rather than a package. If this is specified, we set the source_moduels and forbidden_modules as the package name rather than finding all downstream modules of that package.
a3b20e3
to
83f2e8d
Compare
Following on from the work to add further
as_packages
support to Grimp here, this PR adds theas_packages
options to Forbidden contracts so that we can forbid modules in addition to entire packages. The default behaviour remains, treating all imports as packagesThis change would serve to fix this issue (or implement the feature, I guess?)