Skip to content

Suggestion: Add to PyPi #3

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

Closed
sbdchd opened this issue Jan 4, 2019 · 9 comments
Closed

Suggestion: Add to PyPi #3

sbdchd opened this issue Jan 4, 2019 · 9 comments

Comments

@sbdchd
Copy link

sbdchd commented Jan 4, 2019

What are your thoughts on adding this project to https://pypi.org to make it easier to install and use?

@mkurnikov
Copy link
Member

I wanted to wait for mypy 0.660, because there was a couple of bugs in 0.650 which are important for the plugin. Now it just requires mypy from github as a dependency, I'm not sure whether it's a correct way.

@mkurnikov
Copy link
Member

@sbdchd
I've added it to pypi, could you check whether it works correctly for you?

@sbdchd
Copy link
Author

sbdchd commented Jan 24, 2019

I'm having trouble getting it work.

I've installed the package but by default mypy doesn't find the type stubs.

When I setup the mypy path:

export MYPYPATH=~/project_name/.venv/lib/python3.6/site-packages/django-stubs/

mypy finds the types and reports some errors:

.venv/lib/python3.6/site-packages/django-stubs/http/request.pyi:69:5: error: Incompatible default for argument "default_list" (default has type "None", argument has type "List[str]")
.venv/lib/python3.6/site-packages/django-stubs/http/response.pyi:24:5: error: Incompatible default for argument "content_type" (default has type "None", argument has type "str")
.venv/lib/python3.6/site-packages/django-stubs/http/response.pyi:24:5: error: Incompatible default for argument "status" (default has type "None", argument has type "int")
.venv/lib/python3.6/site-packages/django-stubs/http/response.pyi:24:5: error: Incompatible default for argument "reason" (default has type "None", argument has type "str")
.venv/lib/python3.6/site-packages/django-stubs/http/response.pyi:24:5: error: Incompatible default for argument "charset" (default has type "None", argument has type "str")
.venv/lib/python3.6/site-packages/django-stubs/http/response.pyi:39:5: error: Incompatible default for argument "max_age" (default has type "None", argument has type "int")
.venv/lib/python3.6/site-packages/django-stubs/http/response.pyi:39:5: error: Incompatible default for argument "expires" (default has type "None", argument has type "Union[str, datetime]")
.venv/lib/python3.6/site-packages/django-stubs/http/response.pyi:39:5: error: Incompatible default for argument "domain" (default has type "None", argument has type "str")
.venv/lib/python3.6/site-packages/django-stubs/http/response.pyi:52:5: error: Incompatible default for argument "domain" (default has type "None", argument has type "str")
.venv/lib/python3.6/site-packages/django-stubs/http/response.pyi:146:5: error: Incompatible default for argument "json_dumps_params" (default has type "None", argument has type "Dict[str, Any]")

but it doesn't seem to check the project code.

If I don't set MYPYPATH and instead:

mkdir .venv/lib/mypy/typeshed/third_party/3/django
cp -R .venv/lib/python3.6/site-packages/django-stubs/ .venv/lib/mypy/typeshed/third_party/3/django

Then mypy finds the types correctly.

There is probably a way to have mypy check site-packages/django-stubs but I'm not sure how yet.

I'm using mypy --version 0.570 with the following config:

[mypy]
python_version=3.6
show_column_numbers=True
warn_incomplete_stub = True
warn_redundant_casts = True
warn_unused_configs = True
strict-optional = True
scripts_are_modules = True
incremental = True
ignore_missing_imports = True
check_untyped_defs = True
warn_no_return = True
warn_return_any = True
warn_unused_ignores = True
no_implicit_optional = True
strict_optional=True

Edit: It seems that mypy needs MYPYPATH to point to a directory where each folder is a module.

https://github.com/python/mypy/wiki/Creating-Stubs-For-Python-Modules#using-and-testing-new-stubs-files

So I think

export MYPYPATH=~/project_name/.venv/lib/python3.6/site-packages/django-stubs/

should be

export MYPYPATH=~/project_name/.venv/lib/python3.6/site-packages/django-stubs/django/

although the current directory structure doesn't have that setup.

@mkurnikov
Copy link
Member

Does it work properly with 0.660?

@sbdchd
Copy link
Author

sbdchd commented Jan 24, 2019

I upgraded to mypy --version 0.666 and it is working.

Thanks!

@sbdchd sbdchd closed this as completed Jan 24, 2019
@sbdchd
Copy link
Author

sbdchd commented Jan 24, 2019

While installing the stubs works, the mypy plugin doesn't seem to be working.

plugins =
    mypy_django_plugin.main

which gives the following error:

tox.ini:40:1: error: Error importing plugin 'mypy_django_plugin.main'

This might be related to #2

@mkurnikov
Copy link
Member

I cannot reproduce, could you give me more clues? Could you check whether site-packages directory of your python distribution has mypy_django_plugin directory present?
This command should give you site-packages location to check

python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"

@sbdchd
Copy link
Author

sbdchd commented Jan 24, 2019

site-packages/ does include mypy_django_plugin, but my setup is a little weird as I'm using poetry to manage mydependencies.

I have mypy configured through a tox.ini file that is in the same directory as the virtualenv, .venv/.

@mkurnikov
Copy link
Member

Could you create a new issue mentioning poetry here, with some steps to reproduce? I don't have any experience with poetry, but maybe others do.

@TonyRippy TonyRippy mentioned this issue Dec 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants