-
-
Notifications
You must be signed in to change notification settings - Fork 54
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
[Bug]: python_version + multi-py-version library #348
Comments
Hi @kasium , thank you for opening this, and sorry for the massive delay in responding. I can see how this might potentially be an issue, but I don't have enough to reproduce exactly what is going on. It sounds like there are three conflicting/interacting systems:
One of these is probably the culprit, though it is probably the I'm not familiar with sphinx so I don't know how it is typically used, so it would help if you could describe your sphinx setup so I can better diagnose the error. Are you able to share the source code for this project? If not, can you provide a MVP of the issue? Thanks! |
Hi, thanks for coming back to this issue 😄 . Let me give you some background on my use case:
Given this use case, there is no version I can set in refurb to support this scenario. On the one hand I get false positive errors, on the other I get a sytax error. The only real solution is, to ignore the false positives one by one for files and folders which support the older python versions and then to set python_version in refurb to 3.13 The config enable_all = true
python_version = "3.8" # or "3.13"
quiet = true Python 3.8 compatible code from functools import lru_cache
@lru_cache(maxsize=None)
def foo(): pass python 3.13 compatible code x = 1
match x:
case 1:
print("one")
case 2:
print("two")
case _:
print("other") If you now use with python_version=3.8
with python_version=3.13
|
Ah I see, your project supports Python 3.8+, but has internal parts which use the 3.13 syntax. So the issue is that Refurb uses Mypy under the hood, and Mypy has a global There are 2 ways of going about fixing this:
Both have their pros and cons. With option 1 you get a nice warning if you try to use Python 3.9+ features when you're expecting to support 3.8+, but with option 2 you don't need to scan the codebase multiple times (you could probably do this in parallel, but that's more of an implementation detail). I think option 1 is the easiest, and probably covers your use case the best. What do you think? |
Sounds like a plan. However, I think setting the python_version to the latest and just ignoring invalid findings is also a valid option |
Has your issue already been fixed?
master
branch? See the docs for instructions on how to setup a local build of Refurb.The Bug
Given a multi-py-version library (a library which e..g support python 3.8-3.12), using refurbs python-version can lead to issues. In my case, my documentation which is only generated with python 3.12 contains a custom sphinx plugin. The latest version of sphinx is only compatible with py 3.8 onwards but now refurb complains:
=> error
Version Info
Python Version
3.12.0
Config File
# N/A
Extra Info
None
The text was updated successfully, but these errors were encountered: