Skip to content

Offering Help: Modernised Python Syntax?  #1302

@exhuma

Description

@exhuma

I recently hacked coverage to scratch my own itch and noticed that the internal code could be internally improved with newer Python syntax. The primary thing I noticed (because it was the thing I was hacking on) was the usage of simple tuples in summary.py. Those could be replaced by either namedtuple or even typing.NamedTuple. Maybe there are places where dataclasses could become useful too.

I know this will break compatibility with older Python versions, depending on which features are chosen. With Python 3.6 being EoL since December there is an argument to be made (albeit a weak one) that newer releases of coverage could require 3.7+ which would certainly open up a lot of interesting possibilities.

Type hinting would be an option as well with 3.6+

This does of course raise the issue of code-churn which does not change the functionality of the code and risking regressions with the added issue of messing up git blame to some extent. But I believe a modern syntax helps overall project readability and consequently maintainability as well.

I have been writing Python semi-professionally since the 2.4 release (don't remember the date) and have been writing Python professionally since 2011.

@nedbat: If you are interested in this let me know what kind of things you would like to see and we can agree on the details. If you judge the added-value of this to be too small, or prefer to remain 2.7+ compatible (not sure this is even the case atm) to support older systems, feel free to close this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions