-
Notifications
You must be signed in to change notification settings - Fork 15
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
boto3-stubs not detected as (naively) expected #437
Comments
Possibly related to #45 as well |
Thanks for raising this issue, @tungol, it is indeed interesting. My first thought was that we already have some code to deal with type stubs in FawltyDeps, but after a second look, it does not apply to your scenario (in fact, it only handles the ~opposite scenario)1. However, with this precedence, we are not opposed to adding special handling for common type stubs patterns2, and I wonder if your case might be best solved with a type stubs-related special case. This could be something like:
If we don't make a special case, I think we would somehow need to accept that That said, maybe extras should not be counted as transitive dependencies? On the one hand, when you say On the other hand, you don't control the exact meaning of Also, having to look at extras will carry some of the same complexity/overhead mentioned above. I believe some more thinking is needed here. Is a type stubs-related special case the right way to solve this? Are there more general solutions that solve the problem without regressions or significant overhead? Footnotes
|
The relevant "real" import in this case is just As far as rules for type stubs go, I think that "if TYPE_CHECKING doesn't count" would be a better rule than "import names that look like type stubs" - there are reasons to use type stubs at runtime, and I'd expect those imports to be enforced by fawltydeps. That might be best with a flag to control strictness? I can easily imagine some projects wanting to validate Honestly I've mostly talked myself around to "the right solution is the current behavior" on this. |
I think I agree that a configurable include/exclude I'll leave this issue as a P3 ("we'll get around to it at some point") for now (agree, @mknorps?), and suggest one of these workarounds for you, in the meantime:
|
For context: a comment I made on 5th June, that was removed: From my short exploration, the situation is following:
In |
Describe the bug
boto3-stubs is the type stubs package for boto3, and it's a bit of an oddball because it and several hundred
mypy-boto3-*
packages are programmatically generated from the same code base.The issue at hand is that the documented way to use boto3-stubs relies on the extras mechanism to specify which AWS services you intend to use, rather then including all 300+ of them by default. In poetry's pyproject.toml format an example might be:
boto3-stubs = { extras = ["ec2"], version = "^1.22.2" }
Which means you'll have the base stubs for boto3, and boto3-stubs will pull in
mypy-boto3-ec2
as a dependency. In my project, there's a couple places where I import some types from mypy_boto3_ec2 for annotation purposes, gating it behind aif TYPE_CHECKING
statement.Fawltydeps (correrctly) detects this as an import without a matching dependency. However, it's conceptually a little redundant to list mypy_boto3_ec2 on it's own, because the requested 'ec2' extra for boto3-stubs is pretty explicit already.
Expected behavior
It'd be nice if fawltydeps understood how boto3-stubs uses package extras. That said, following package extras is probably the wrong thing to do in a lot of other cases, and I don't know if there's a way to handle that short of just special-casing it.
I think this issue is slightly similar to the case in #176 , but only in that boto3-stubs and
mypy-boto3-*
packages are conceptually a single unit while being separate packages in implementation. The specific namespace issues in that ticket have no parallel here.I waffled on opening this ticket at all. I think there's a pretty reasonable case to made that taking the explicit dependency is the right thing to do when you get to the point of importing something. It did surprise me though, because I don't usually think of
mypy-boto3-ec2
as a separate package fromboto3-stubs
.The text was updated successfully, but these errors were encountered: