Skip to content

Ability to ignore type dependencies in poly check #336

@davclark

Description

@davclark

Is your feature request related to a problem? Please describe.
I would ideally not need to customize the poly check command to ignore type dependencies. These are easy to fence in regular code like so, which allows installation in your test env, but not your production / default env:

if TYPE_CHECKING:
    from mypy_boto3_s3.service_resource import Object as S3Object

However, with that code in my default build, poly check yields 🤔 Cannot locate mypy_boto3_s3 in my_project.

Describe the solution you'd like
While I can use an alias as described in #206, it would be nice if we could ignore dependencies that are guarded by if typing.TYPE_CHECKING

I'd be happy to chip in on this, but I'd love a brief pointer to understanding how the existing code parses out imports. I'm somehow not finding it, but it's rather cool and I'd love to understand it better.

Describe alternatives you've considered
poly check --alias boto3=mypy_boto3_s3 works, it's just not as nice of an OOtB experience.

Obviously this is not hard - but as a tool to help drive large projects towards better SW eng practices, it would be great for polylith to have a seamless interaction with common patterns for mypy (or perhaps ty if you're up on the latest, which I most certainly am not).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions