getsentry / sentry-python

The official Python SDK for Sentry.io
https://sentry.io/for/python/
MIT License
1.93k stars 509 forks source link

Enforce consistent typing syntax #3812

Open szokeasaurusrex opened 20 hours ago

szokeasaurusrex commented 20 hours ago

As of when this issue is being written, we use type comments in our type hints, rather than the new Python type annotations:

# Conforms with our coding style
def foo(num, name):
    # type: (int, str) -> str
    return f"{num} is {name}'s favorite number"

# Does not conform with our coding style
def bar(num: int, name: str) -> str:
    return f"{num} is {name}'s favorite number"

We have had some instances of the non-conformant form getting through code review (e.g. #3717). So that we don't need to rely on human-error-prone manual verification that we use the conformant syntax, we should introduce automated checks to enforce our preferred style.

If we change our preferred syntax before we get around to implementing this issue, then we should enforce that syntax instead.