Skip to content

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

@Zer0x00

Description

@Zer0x00

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions