Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--exclude on python < 3.13 #489

Open
jorenham opened this issue Dec 8, 2024 · 3 comments
Open

--exclude on python < 3.13 #489

jorenham opened this issue Dec 8, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@jorenham
Copy link

jorenham commented Dec 8, 2024

Context

#451 introduced the --exclude option to specify which files to exclude from formatting using globs. This is an essential feature for anyone that uses things like submodules, vendors 3rd party libs, or uses in-project virtual environments, which includes e.g. every uv user.
However, this can only be used on python >= 3.13. Attempting to do so on other Python versions will result in a error, and will prevent using mdformat altogether.
In practice, many projects support multiple python versions, and for reasons of compatibility use the lowest supported version for development and testing, and can therefore not use --exclude.

Proposal

Make --exclude available on python<3.13 as well. Something like glob.translate could be used for this.

@hukkin
Copy link
Owner

hukkin commented Dec 9, 2024

Thanks for the issue!

glob.translate was added in Python 3.13, so isn't useful here.

A PR is welcome, if there is a pathlib.PurePath.full_match backport on PyPI, or other library that can mimic its behavior.

@hukkin
Copy link
Owner

hukkin commented Dec 9, 2024

Not sure if it works for you, but using a tool like pre-commit will allow excluding files on older Python versions (and comes with other benefits too).

@jorenham
Copy link
Author

jorenham commented Dec 9, 2024

yea in scipy-stubs we're also running in the pre-commit, but I'm not the biggest fan of it, and don't want to make the CI fully dependent on it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants