Hey folks - I have this code: ```from typing impo...
# general
l
Hey folks - I have this code:
Copy code
from typing import TYPE_CHECKING, TypeVar
if TYPE_CHECKING:
    from _typeshed import SupportsRichComparison
    K = TypeVar("K", bound=SupportsRichComparison)
else:
    K = TypeVar("K")
But dependency inference fails with this error:
Copy code
UnownedDependencyError: Pants cannot infer owners for the following imports in the target projects/simulator/engine/utils/range_map_helper.py:

  * _typeshed.SupportsRichComparison (line: 5)
My first thought was that I probably need to add something to
module_mapping
, but
_typeshed
is an stdlib module, and I don't know how to add a mapping to the stdlib. Is that possible? For now, I have this marked with
no-infer-dep
, but I'd like to figure out how to fix it properly.
c
👀 "typeshed includes a package _typeshed as part of the standard library. This package and its submodules contains utility types, but is not available at runtime. " TIL
1
😮 1
👀 1
l
Same behavior without
use_rust_parser
!
Upon further thought, I'm very ok with the
no-infer-dep
solution for this. I don't see any possible foot-gun it could cause, since it's in the stdlib. But if it seems like a bug rather than me holding it wrong, might be worth fixing so others don't run into it in the future.
f
thanks for posting this, @lemon-oxygen-2929! I've raised a PR that adds this module to the default list of unownable targets https://github.com/pantsbuild/pants/pull/20468. This is likely to end up in 2.20, but for now I am afraid you'd have to rely on using ignore pragmas, hope there aren't many!
🙏 1
l
Thank you! I have no problem relying on ignore until then! I was going to file a bug tomorrow if nobody replied to say this was intended behavior, but now I don't even have to do that. Much obliged.
🙌 1