Skip to content

import of constraints fails if done before subtypes #6329

Closed
@SpamapS

Description

@SpamapS
  • Are you reporting a bug, or opening a feature request?

bug

  • 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.
import mypy.constraints
  • What is the actual behavior/output?
(mypy) clint@clint-ThinkPad-X1-Carbon-6th:~$ pip install mypy
Collecting mypy
  Downloading https://files.pythonhosted.org/packages/fc/4b/b2376fffd1416b76da0708dd8c8ab46c80cd2364c42212059587ae92f1d8/mypy-0.660-py3-none-any.whl (1.4MB)
    100% |████████████████████████████████| 1.4MB 11.5MB/s 
Collecting mypy-extensions<0.5.0,>=0.4.0 (from mypy)
  Using cached https://files.pythonhosted.org/packages/4d/72/8d54e2b296631b9b14961d583e56e90d9d7fba8a240d5ce7f1113cc5e887/mypy_extensions-0.4.1-py2.py3-none-any.whl
Collecting typed-ast<1.3.0,>=1.2.0 (from mypy)
  Downloading https://files.pythonhosted.org/packages/52/6c/57ecbb2ecb80274b7f2b7f95d0937de310aa2e66839d7ae9436881525b23/typed_ast-1.2.0-cp36-cp36m-manylinux1_x86_64.whl (724kB)
    100% |████████████████████████████████| 727kB 10.9MB/s 
Installing collected packages: mypy-extensions, typed-ast, mypy
Successfully installed mypy-0.660 mypy-extensions-0.4.1 typed-ast-1.2.0
(mypy) clint@clint-ThinkPad-X1-Carbon-6th:~$ python3
Python 3.6.7 (default, Oct 22 2018, 11:32:17) 
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import mypy.constraints
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/clint/v/mypy/lib/python3.6/site-packages/mypy/constraints.py", line 11, in <module>
    import mypy.subtypes
  File "/home/clint/v/mypy/lib/python3.6/site-packages/mypy/subtypes.py", line 971, in <module>
    return_constraint_direction: int = mypy.constraints.SUBTYPE_OF,
AttributeError: module 'mypy' has no attribute 'constraints'
>>> 
  • What is the behavior/output you expect?

imports of public modules should not cause AttributeErrors.

  • What are the versions of mypy and Python you are using?

mypy 0.660
python 3.6.7

Do you see the same issue after installing mypy from Git master?

No

Python 3.6.7 (default, Oct 22 2018, 11:32:17) 
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import mypy.constraints
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/clint/src/misc/mypy/mypy/constraints.py", line 11, in <module>
    import mypy.subtypes
  File "/home/clint/src/misc/mypy/mypy/subtypes.py", line 971, in <module>
    return_constraint_direction: int = mypy.constraints.SUBTYPE_OF,
AttributeError: module 'mypy' has no attribute 'constraints'
>>> 

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions