You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please provide more information to help us understand the issue:
mypy doesn't see an instance attribute is checked by a decorator, in an instance method.
Please insert below the code you are checking with mypy,
or a mock-up repro if the source is private. We would appreciate
if you try to simplify your case to a minimal repro.
root@8506a4af0701:/app# mypy tests/test_instance_decorator.py
tests/test_instance_decorator.py:56: error: Item "None" of "Optional[User]" has no attribute "role"
tests/test_instance_decorator.py:59: error: Incompatible types in assignment (expression has type "None", variable has type "Role")
Found 2 errors in 1 file (checked 1 source file)
pytest output:
root@8506a4af0701:/app# py.test tests/test_instance_decorator.py -s -vv
==================================================================== test session starts ====================================================================
platform linux -- Python 3.6.8, pytest-4.6.6, py-1.8.0, pluggy-0.13.0 -- /usr/bin/python3
cachedir: .pytest_cache
rootdir: /anmo-app
plugins: cov-2.8.1
collected 2 items
tests/test_instance_decorator.py::test_initiator_is_required Yep, this is expected
PASSED
tests/test_instance_decorator.py::test_initiator_disabled_on_purpose User updated without initiator
PASSED
What is the behavior/output you expect?
I would expect mypy realized I'm checking that instance attribute in the decorator.
What are the versions of mypy and Python you are using?
7.4.0
What are the mypy flags you are using? (For example --strict-optional)
None
More context about what I'm trying to do
I'm building a small app that will be wrapped in a REST API. There are Users that have roles (user and admin). The business logic says a user's role can be elevated only by an admin (so that's what's up with the initiator). However, I want to use this same command from CLI, where I can manually disable the initiator check.
The text was updated successfully, but these errors were encountered:
Please provide more information to help us understand the issue:
mypy doesn't see an instance attribute is checked by a decorator, in an instance method.
or a mock-up repro if the source is private. We would appreciate
if you try to simplify your case to a minimal repro.
mypy output
pytest output:
What is the behavior/output you expect?
I would expect mypy realized I'm checking that instance attribute in the decorator.
What are the versions of mypy and Python you are using?
7.4.0
What are the mypy flags you are using? (For example --strict-optional)
None
More context about what I'm trying to do
I'm building a small app that will be wrapped in a REST API. There are
User
s that have roles (user
andadmin
). The business logic says a user's role can be elevated only by anadmin
(so that's what's up with theinitiator
). However, I want to use this same command from CLI, where I can manually disable the initiator check.The text was updated successfully, but these errors were encountered: