Skip to content
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

Ignore 'TYPE_CHECKING' imports if string annotation is used #661

Closed
Zer0x00 opened this issue Apr 4, 2024 · 1 comment · Fixed by #662
Closed

Ignore 'TYPE_CHECKING' imports if string annotation is used #661

Zer0x00 opened this issue Apr 4, 2024 · 1 comment · Fixed by #662
Labels
bug Something isn't working

Comments

@Zer0x00
Copy link

Zer0x00 commented Apr 4, 2024

The latest release did include a feature to skip type checking blocks. (Thanks for it!)

Currently it works only if it finds the TYPE_CHECKING block in combination with from __future__ import annotations.
But as far as my understanding goes it is also perfectly fine to not have the annotations module imported but annotate them as a string like this:

from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from aws_lambda_powertools.utilities.data_classes import SQSEvent

def handle_sqs_event(event: 'SQSEvent', _context)
   ...

deptry currently doesn't respect those cases.

@mkniewallner
Copy link
Collaborator

Thanks for the report. Indeed, this is an oversight from me. This should be fixed with #662.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants