-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
(π) crash with --pretty
from attrs raising an error in the wrong file
#17535
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
Comments
I am seeing what might be a related issue. For me it doesn't result in a crash, but I am getting errors for rows which aren't in my file. I'm getting a bunch of errors like:
My file It happens on three different files in my codebase, and what they all have in common is that they all have the import I'm using python 3.8, and in the file in It looks like somehow mypy thinks those lines are in my source file? Another strange detail: on the second run (if I already have a I can reproduce it like this: from pydantic_settings import BaseSettings
class Foo(BaseSettings):
pass
environment: It doesn't replicate with the mypy plugin disabled, but it doesn't replicate with mypy 1.10.1 either. |
@brianmedigate add |
confirmed, you are correct. thanks |
I have the same problem. A file that imports from pydantic_settings gets a bunch of errors related to 3.10 union syntax. That syntax is used in pydantic-settings, but it is not used in my file. Also, the line numbers stated in the mypy output are greater than the number of lines in my file. It somehow seems to think some pydantic_settings file is my file. If the mypy cache exists, the error does not show up. If I delete the cache and re-run, the errors are back. Calling mypy with
Will this problem be tracked in this issue? (It was not clear to me from the title that this was the same problem I had.) |
@brianmedigate I am witnessing the behavior you described in files with |
@KotlinIsland does your use case include pydantic? I wonder if we should cross-post this to the pydantic issues page? |
Hitting the same issue, and I'm using Pydantic's |
Flagged it to |
Pydantic dev here βΒ I'll note that I can reproduce the error with Python 3.9.19 and Mypy 1.11.0, but the issue goes away if I use python >=3.10 or mypy <=1.10.1. I do think it has something to do with the fact that Perhaps it is an issue with detecting the |
Thanks a bunch for the additional pointers here, @dmontagu. |
I found it from the primer output in a basedmypy pull request, the primer is much more comprehensive in basedmypy, so it hasn't been detected in mypy |
Any updates here? |
OK, I looked at it and in both cases it is a bug in the plugins, not sure why they are surfaced only now. For |
Looking at commit history, the pydantic issue was likely triggered by #17371 cc @hauntsaninja The default copy behavior for union is now to carry the |
@ilevkivskyi if you end up needing to modify the attrs plugin, I am happy to take responsibility (or at least to try to take responsibility π ) for adapting the same fix to the pydantic plugin. I would just appreciate if you could share a link to any such PR on this issue (or vice versa). To be clear, the pydantic plugin was adapted from the dataclasses plugin some time ago, and every so often I try to update it to reflect updates/improvements in the dataclasses plugin; if the dataclasses and/or attrs plugins now copy the "correct" subset of metadata data (instead of all supertype method metadata), I can try to modify the pydantic plugin to handle it correctly, it would just be helpful to have some kind of reference to a spot where this is being done "properly" from your perspective. |
I made a change in basedmypy to prevent the crash if the requested source code doesn't exist |
@ilevkivskyi @dmontagu any update on this? Is there an issue for this on the pydantic issue tracker? |
After some discussions, we decided that the real underlying problem is using types as error context, and this needs to be prohibited altogether. This is however a relatively large refactoring, so will take some time. I may have time to work on this (or on the quick fix I mentioned above) but no guarantees. |
Any updates on this one? |
threading.py:316: error
, threading only has 43 lines in it.The text was updated successfully, but these errors were encountered: