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

Consider packaging misc.proper_plugin as a part of mypy #16035

Closed
sobolevn opened this issue Sep 4, 2023 · 0 comments · Fixed by #16036
Closed

Consider packaging misc.proper_plugin as a part of mypy #16035

sobolevn opened this issue Sep 4, 2023 · 0 comments · Fixed by #16036
Assignees
Labels
feature topic-plugins The plugin API and ideas for new plugins

Comments

@sobolevn
Copy link
Member

sobolevn commented Sep 4, 2023

It might be very helpful for plugin developers, because in my own code I have a lot of warnings when I use this plugin.

The error is really common, so the need is quite high.
Since it does not have any 3rd party dependencies, we are also free to just move it to mypy/plugins

We can also add a note about it in the docs: https://mypy.readthedocs.io/en/stable/extending_mypy.html

@sobolevn sobolevn added feature topic-plugins The plugin API and ideas for new plugins labels Sep 4, 2023
@sobolevn sobolevn self-assigned this Sep 4, 2023
sobolevn added a commit that referenced this issue Sep 4, 2023
I modified 

```diff
diff --git mypy/binder.py mypy/binder.py
index 8a68f24f6..194883f86 100644
--- mypy/binder.py
+++ mypy/binder.py
@@ -345,7 +345,7 @@ class ConditionalTypeBinder:
             self._cleanse_key(dep)
 
     def most_recent_enclosing_type(self, expr: BindableExpression, type: Type) -> Type | None:
-        type = get_proper_type(type)
+        # type = get_proper_type(type)
         if isinstance(type, AnyType):
             return get_declaration(expr)
         key = literal_hash(expr)
```

to see if it still works. It is:

```python
» python runtests.py self
run self: ['/Users/sobolev/Desktop/mypy/.venv/bin/python', '-m', 'mypy', '--config-file', 'mypy_self_check.ini', '-p', 'mypy', '-p', 'mypyc']
mypy/binder.py:349: error: Never apply isinstance() to unexpanded types; use
mypy.types.get_proper_type() first  [misc]
            if isinstance(type, AnyType):
               ^~~~~~~~~~~~~~~~~~~~~~~~~
mypy/binder.py:349: note: If you pass on the original type after the check, always use its unexpanded version
Found 1 error in 1 file (checked 288 source files)

FAILED: self
```

I will add this plugin to my CI checks in like ~5 plugins I maintain :)

- https://github.com/typeddjango/django-stubs
- https://github.com/typeddjango/djangorestframework-stubs
- https://github.com/dry-python/returns
- https://github.com/dry-python/classes
- https://github.com/wemake-services/mypy-extras

Closes #16035
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature topic-plugins The plugin API and ideas for new plugins
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant