django / asgiref

ASGI specification and utilities
https://asgi.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
1.46k stars 207 forks source link

Remove unnecessarily complicated backwards compatibility code #408

Closed kimvais closed 12 months ago

kimvais commented 1 year ago

asyncio.iscoroutinefunction would be needed as a fallback only for Python 3.4 as 3.3 didn't have asyncio and 3.5 introduced inspect.iscoroutinefunction

Also made the 3.12 version check explicit instead of implicit based on the existence of the decorator.

andrewgodwin commented 1 year ago

What do you see as the advantage of making the version check based on the number rather than the attribute existing? I'd rather do it on the presence of the attribute in case something like PyPy hasn't implemented all of a new inspect yet.

kimvais commented 1 year ago

Well, I'm a strong believer that "Readability counts" is the most important piece of PEP 20 and in my opinion making any code less consistent (and therefore arguably less readable) because some third-party static analysis tool might not be up to speed is counterproductive.

But fair enough, no objection on changing the if clause back to what it was. I guess I got a bit distracted by the bit confusing comment :)