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

Type checking with mypy #39

Open
caseydm opened this issue Sep 15, 2020 · 0 comments
Open

Type checking with mypy #39

caseydm opened this issue Sep 15, 2020 · 0 comments

Comments

@caseydm
Copy link

caseydm commented Sep 15, 2020

I'm using mypy with the Django plugin. When I reference request.user_agent with a function like this:

from django.core.handlers.wsgi import WSGIRequest

def get_application(request: WSGIRequest) -> Application:
    if request.user_agent.is_mobile:
      pass

mypy complains:

error: "WSGIRequest" has no attribute "user_agent"

Is there a way to resolve this error? All I can think of right now is to ignore it with # type: ignore.

Here is the mypy config file for reference:

[mypy]
ignore_missing_imports = True

plugins =
    mypy_django_plugin.main

[mypy.plugins.django-stubs]
django_settings_module = myapp.settings.base
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@caseydm and others