seddonym / import-linter

Import Linter allows you to define and enforce rules for the internal and external imports within your Python project.
https://import-linter.readthedocs.io/
BSD 2-Clause "Simplified" License
679 stars 48 forks source link

Use stdlib tomllib package on Python 3.11 #146

Closed djmattyg007 closed 1 year ago

djmattyg007 commented 1 year ago

There's no need to use a third party package for reading TOML files on Python 3.11, so it would be nice to avoid the additional dependency.

seddonym commented 1 year ago

Great idea! Happy to consider pull requests for this (the submitter will probably need to have a decent understanding of tox). Otherwise I'll probably get around to it at some point.

mwgamble commented 1 year ago

@seddonym How would you feel about moving away from the toml library for older versions of Python? tomli and tomlkit are both much more active and have better support. Most Python projects have made the switch.

seddonym commented 1 year ago

How would you feel about moving away from the toml library for older versions of Python?

I don't have any particular attachment to that library, though equally I haven't experienced any problems with it either. I guess I would say that in the absence of any problems, maybe there are more worthwhile things to spend time on, but certainly open to being persuaded otherwise.

djmattyg007 commented 1 year ago

The stdlib package tomllib comes from the third party package tomli. This means they have the same interface, so switching makes sense if there's no other reason to stay.

mwgamble commented 1 year ago

tomli is what's used by coverage, so it makes sense to use the same thing.

mwgamble commented 1 year ago

@seddonym How would you feel about making tomli a compulsory dependency (restricted to Python versions older than 3.11)?

It could help simplify things:

Most users probably already have tomli installed anyway, because it's a compulsory dependency of other major packages such as black, mypy, pytest, pylint and coverage. Also, I'm struggling to get the type-checking working with tomli being an optional dependency :(

mwgamble commented 1 year ago

I've created #152, which switches to tomllib and tomli on older versions of Python. It makes tomli a compulsory dependency, because it's likely that users already have it installed anyway.