-
Notifications
You must be signed in to change notification settings - Fork 25
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
Vermin reports that code is incompatible but it is #230
Comments
In --violations mode, the CLI requires that the number of "--target" specified is the same as the number of requirements. Many users no longer care about Python 2, but may write a simple file which is compatible with Python 2 by chance. In that case, Vermin will return a Python 2.x compatibility entry, and --violations will fail unless a target is specified for Python 2. However, there's no way to specify a target of "I don't care about this version", so these users would be forced to run with something like "-t=2.7- -t=3.6-". Except this would fail on their normal code, which is incompatible with Python 2.x. To get around this, start comparing by the major version of Python. Only compare the versions which are in common between the requirements and target. If there are no versions in common, fail. If a target major version is missing from the requirements, fail. This allows users who only specify a "3.x-" target to know that Vermin will succeed on any code, even simple code which is 2.x compatible too. This fixes netromdk#230. Signed-off-by: Stephen Brennan <stephen@brennan.io>
Yeah, I encountered the same issue - simple code which happens to be Python 2.x compatible will get flagged because I've only provided Python 3.x compatibility targets. The issue is that there's basically a list of requirements, and a list of targets. The requirements includes an entry for Python 2.x and for 3.x. But you've only specified targets for 3.x. So when the code goes to check the requirements, it sees that the lengths of these two lists don't match, and fails. My pull request (#234) adjusts the logic to align the targets and requirements on their major version, so that the lists don't need to match in length. |
In --violations mode, the CLI requires that the number of "--target" specified is the same as the number of requirements. Many users no longer care about Python 2, but may write a simple file which is compatible with Python 2 by chance. In that case, Vermin will return a Python 2.x compatibility entry, and --violations will fail unless a target is specified for Python 2. However, there's no way to specify a target of "I don't care about this version", so these users would be forced to run with something like "-t=2.7- -t=3.6-". Except this would fail on their normal code, which is incompatible with Python 2.x. To get around this, start comparing by the major version of Python. Only compare the versions which are in common between the requirements and target. If there are no versions in common, fail. If a target major version is missing from the requirements, fail. This allows users who only specify a "3.x-" target to know that Vermin will succeed on any code, even simple code which is 2.x compatible too. This fixes netromdk#230. Signed-off-by: Stephen Brennan <stephen@brennan.io>
In --violations mode, the CLI requires that the number of "--target" specified is the same as the number of requirements. Many users no longer care about Python 2, but may write a simple file which is compatible with Python 2 by chance. In that case, Vermin will return a Python 2.x compatibility entry, and --violations will fail unless a target is specified for Python 2. However, there's no way to specify a target of "I don't care about this version", so these users would be forced to run with something like "-t=2.7- -t=3.6-". Except this would fail on their normal code, which is incompatible with Python 2.x. To get around this, start comparing by the major version of Python. Only compare the versions which are in common between the requirements and target. If there are no versions in common, fail. If a target major version is missing from the requirements, fail. This allows users who only specify a "3.x-" target to know that Vermin will succeed on any code, even simple code which is 2.x compatible too. This fixes netromdk#230. Signed-off-by: Stephen Brennan <stephen@brennan.io>
@WhyNotHugo finally merged it :) thanks again, @brenns10! Version 1.6 will be released tomorrow. |
Vermin 1.6.0 was recently released, which contains a fix for netromdk/vermin#230. This was a rather odd corner case, in which Vermin would fail when code was compatible with 2.x and 3.x, yet the command line only required compatibility with 3.x. Since pre-commit runs against only files that changed, this was possible, for example with small test files. I'm not sure if I encountered it in drgn (I know I did with drgn-tools), but it's good to have the fix. I used pre-commit autoupdate, so we have the latest version of each hook now. In particular, this commit surpasses mypy 0.971, which is the last version to support Python 3.6 at runtime. Mypy still supports targeting Python 3.6[1]. [1]: https://mypy-lang.blogspot.com/2022/07/mypy-0971-released.html Two new errors were surfaced with the new hooks: 1. Mypy complained about the pattern "os.exit(exception)". I've replaced these so they explicitly use str: "os.exit(str(exception))". drgn/cli.py:283: error: Argument 1 to "exit" has incompatible type "OSError"; expected "str | int | None" [arg-type] 2. Vermin complained that "int.is_integer()" was introduced 3.12. I surmised that it was unable to infer that its usage was guaranteed to be against a float, and the reason was due to the division operation against an integer. I changed the integer literal to a float literal, which resolved the issue. !2, 3.12 drgn/helpers/common/format.py 'int.is_integer' member requires !2, 3.12 Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com>
Vermin 1.6.0 was recently released, which contains a fix for netromdk/vermin#230. This was a rather odd corner case, in which Vermin would fail when code was compatible with 2.x and 3.x, yet the command line only required compatibility with 3.x. Since pre-commit runs against only files that changed, this was possible, for example with small test files. I'm not sure if I encountered it in drgn (I know I did with drgn-tools), but it's good to have the fix. I used pre-commit autoupdate, so we have the latest version of each hook now. In particular, this commit surpasses mypy 0.971, which is the last version to support Python 3.6 at runtime. Mypy still supports targeting Python 3.6[1]. [1]: https://mypy-lang.blogspot.com/2022/07/mypy-0971-released.html Two new errors were surfaced with the new hooks: 1. Mypy complained about the pattern "os.exit(exception)". I've replaced these so they explicitly use str: "os.exit(str(exception))". drgn/cli.py:283: error: Argument 1 to "exit" has incompatible type "OSError"; expected "str | int | None" [arg-type] 2. Vermin complained that "int.is_integer()" was introduced 3.12. I surmised that it was unable to infer that its usage was guaranteed to be against a float, and the reason was due to the division operation against an integer. I changed the integer literal to a float literal, which resolved the issue. !2, 3.12 drgn/helpers/common/format.py 'int.is_integer' member requires !2, 3.12 Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com>
Describe the bug
Vermin reports that my codebase is not compatible with 3.8, but it is. Oddly, it points out:
Which sounds like it should be fine to me.
To Reproduce
Vermin fails, indicating that this code doesn't run for the specified version:
Expected behavior
This should work just fine.
Environment (please complete the following information):
Additional context
Full file is here: https://github.com/pimutils/khal/blob/f5ca8883f2e3d8a403d7a6d16fa4f552b6b69283/setup.py
The text was updated successfully, but these errors were encountered: