Skip to content

Commit

Permalink
Add Import.implicit and .excluded methods for excluding known implici…
Browse files Browse the repository at this point in the history
…t modules.

Ref #8
  • Loading branch information
jaraco committed Sep 21, 2024
1 parent 3a932a5 commit 515f403
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,27 @@ def builtin(self):
# for compatibility
return self.standard()

def implicit(self):
"""
Is this module implicitly available (based on other conditions)?
For example, ``_typeshed`` is made available at runtime by mypy
and other type checkers and will not have a distribution that
supplies it.
>>> Import('_typeshed.StrPath').implicit()
True
>>> Import('._typeshed').implicit()
False
>>> Import('os').implicit()
False
"""
implicit = {'_typeshed'}
return self.top in implicit

def excluded(self):
return self.implicit() or self.standard()

CPE = jaraco.context.ExceptionTrap(subprocess.CalledProcessError)

@staticmethod
Expand Down

0 comments on commit 515f403

Please sign in to comment.