`singledispatch` and `singledispatchmethod` lead to false positives for TCH001-003
I have
type-checking-sqlalchemy-enabled = False
but it doesn't seem to affect
from sqlalchemy.sql.expression import Insert, Select
@singledispatchmethod
def _cache_update_clause(self, query: QueryType) -> Insert:
flake8 will tell me Insert should be in a TYPE_CHECKING block however it is required at Runtime.
There is a similar thing with
from sqlalchemy.engine import CursorResult
@antazoey This actually looks like an issue with @singledispatchmethod not with the SQLAlchemy integration, since singledispatch needs to be able to inspect the signature at runtime so it can do the dynamic dispatch based on argument types.
This definitely seems like something we should support though, considering it's part of the standard library. Feel free to open a PR if you want to take a crack at this.
That being said SQLAlchemy's @declared_attr may be affected too, the SQLAlchemy plugin doesn't currently handle it and there are probably some @declared_attr that require runtime access to some parts of the return annotation.
@Daverball Yeah, I actually left that out too, a fuller code snippet:
@singledispatchmethod
def _cache_update_clause(self, query: QueryType) -> Insert:
shows the decorator usage. edit: updated the description
This definitely seems like something we should support though, considering it's part of the standard library. Feel free to open a PR if you want to take a crack at this.
I can take a look once I have time!