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

Use vermin to check Python-compat #1275

Merged
merged 1 commit into from
Jun 20, 2023
Merged

Use vermin to check Python-compat #1275

merged 1 commit into from
Jun 20, 2023

Conversation

WhyNotHugo
Copy link
Member

Vermin checks source code for anything that might be incompatible with older Python versions.

This prevents accidentally using a feature from Python 3.10 when we're still supporting 3.8.

While tests ideally detect this, there will always be some bits not covered by tests.

Using a non-release revision since we need some unreleased changes to deal with zoneinfo backports.

See: netromdk/vermin#189

Vermin checks source code for anything that might be incompatible with
older Python versions.

This prevents accidentally using a feature from Python 3.10 when we're
still supporting 3.8.

While tests ideally detect this, there will always be some bits not
covered by tests.

Using a non-release revision since we need some unreleased changes to
deal with zoneinfo backports.

See: netromdk/vermin#189
@geier
Copy link
Member

geier commented Jun 20, 2023

Nice.

Seems to work #1276

doesn't catch def test(a: int | str) but does catch 'test'.removeprefix(). Agree, might be helpful.

@geier geier merged commit e92d747 into master Jun 20, 2023
4 checks passed
@geier geier deleted the vermin branch June 20, 2023 17:25
@netromdk
Copy link

netromdk commented Jun 21, 2023

Hi there. Vermin author here.

doesn't catch def test(a: int | str) but does catch 'test'.removeprefix(). Agree, might be helpful.

If you are using union types, then you must explicitly enable the detection via --feature union-types. As you can read in the FAQ:

Detecting union types (X | Y PEP 604) can be tricky because Vermin doesn't know all underlying details of constants and types since it parses and traverses the AST. For this reason, heuristics are employed and this can sometimes yield incorrect results (netromdk/vermin#103). To enable (unstable) union types detection, use --feature union-types.

If you have:

def test(a: int | str):
  pass

Then you will get the following using --feature union-types:

!2, 3.10     /tmp/test.py
  L1: annotations require !2, 3.0
  L1: union types as `X | Y` require !2, 3.10

@geier
Copy link
Member

geier commented Jun 23, 2023

Thanks @netromdk for the information!

I was testing basically testing test(a: int | str) because it was the first feature I could think of that python 3.8 doesn't support. I don't think we need to enable that for now.

@netromdk
Copy link

Sure thing! :)

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

Successfully merging this pull request may close these issues.

3 participants