`python-use-type-annotations` wrongfully complains about comments starting with `type`
Opened this issue · 4 comments
For example:
# type is a keyword in python, so don't name a variable that
ticket_type = models.NullCharField(
max_length=255,
db_column='type',
)
I think we should have the regex check for comments starting with type:
instead of just type
.
this is intentional, to catch common typos like:
x = 5 # type Optional[int]
in your case it's pretty easy to work around,
# `type` is a keyword in ...
but also I'm not sure that comment is a useful one anyway?
I ran into the same issue when creating a byte string by concatenating, doing something like:
raw += b"\x00" # type for PONG message
Writing `type` with the backticks is not really appropriate here.
Maybe catching typos could have its own hook (if necessary), and python-use-type-annotations
would have a simple spec of complaining about valid comment type annotations? What does @asottile think?
I've already put my thoughts above
How about checking for word boundary after type
? This hook triggers even for stuff like
# types_of_specie