Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

Hypothesis is broken on python2.7 and 3.5 #2972

Closed
guihao-liang opened this issue Jan 31, 2020 · 6 comments · Fixed by #2973
Closed

Hypothesis is broken on python2.7 and 3.5 #2972

guihao-liang opened this issue Jan 31, 2020 · 6 comments · Fixed by #2973
Labels
dependencies Pull requests that update a dependency file

Comments

@guihao-liang
Copy link
Collaborator

guihao-liang commented Jan 31, 2020

On our current main branch,

(env) ➜  gui-4-27 git:(master) pytest --version
Traceback (most recent call last):
  File "/Users/guihaoliang/Work/gui-4-27/deps/env/bin/pytest", line 10, in <module>
    sys.exit(main())
  File "/Users/guihaoliang/Work/gui-4-27/deps/env/lib/python2.7/site-packages/_pytest/config/__init__.py", line 63, in main
    config = _prepareconfig(args, plugins)
  File "/Users/guihaoliang/Work/gui-4-27/deps/env/lib/python2.7/site-packages/_pytest/config/__init__.py", line 207, in _prepareconfig
    pluginmanager=pluginmanager, args=args
  File "/Users/guihaoliang/Work/gui-4-27/deps/env/lib/python2.7/site-packages/pluggy/hooks.py", line 289, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "/Users/guihaoliang/Work/gui-4-27/deps/env/lib/python2.7/site-packages/pluggy/manager.py", line 87, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/Users/guihaoliang/Work/gui-4-27/deps/env/lib/python2.7/site-packages/pluggy/manager.py", line 81, in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
  File "/Users/guihaoliang/Work/gui-4-27/deps/env/lib/python2.7/site-packages/pluggy/callers.py", line 203, in _multicall
    gen.send(outcome)
  File "/Users/guihaoliang/Work/gui-4-27/deps/env/lib/python2.7/site-packages/_pytest/helpconfig.py", line 94, in pytest_cmdline_parse
    config = outcome.get_result()
  File "/Users/guihaoliang/Work/gui-4-27/deps/env/lib/python2.7/site-packages/pluggy/callers.py", line 81, in get_result
    _reraise(*ex)  # noqa
  File "/Users/guihaoliang/Work/gui-4-27/deps/env/lib/python2.7/site-packages/pluggy/callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "/Users/guihaoliang/Work/gui-4-27/deps/env/lib/python2.7/site-packages/_pytest/config/__init__.py", line 687, in pytest_cmdline_parse
    self.parse(args)
  File "/Users/guihaoliang/Work/gui-4-27/deps/env/lib/python2.7/site-packages/_pytest/config/__init__.py", line 895, in parse
    self._preparse(args, addopts=addopts)
  File "/Users/guihaoliang/Work/gui-4-27/deps/env/lib/python2.7/site-packages/_pytest/config/__init__.py", line 841, in _preparse
    self.pluginmanager.load_setuptools_entrypoints("pytest11")
  File "/Users/guihaoliang/Work/gui-4-27/deps/env/lib/python2.7/site-packages/pluggy/manager.py", line 292, in load_setuptools_entrypoints
    plugin = ep.load()
  File "/Users/guihaoliang/Work/gui-4-27/deps/env/lib/python2.7/site-packages/importlib_metadata/__init__.py", line 90, in load
    module = import_module(match.group('module'))
  File "/Users/guihaoliang/.pyenv/versions/2.7.16/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/Users/guihaoliang/Work/gui-4-27/deps/env/lib/python2.7/site-packages/hypothesis/__init__.py", line 27, in <module>
    from hypothesis._settings import HealthCheck, Phase, Verbosity, settings, unlimited
  File "/Users/guihaoliang/Work/gui-4-27/deps/env/lib/python2.7/site-packages/_pytest/assertion/rewrite.py", line 304, in load_module
    exec(co, mod.__dict__)
  File "/Users/guihaoliang/Work/gui-4-27/deps/env/lib/python2.7/site-packages/hypothesis/_settings.py", line 40, in <module>
    from hypothesis.internal.compat import integer_types, quiet_raise, string_types
  File "/Users/guihaoliang/Work/gui-4-27/deps/env/lib/python2.7/site-packages/_pytest/assertion/rewrite.py", line 304, in load_module
    exec(co, mod.__dict__)
  File "/Users/guihaoliang/Work/gui-4-27/deps/env/lib/python2.7/site-packages/hypothesis/internal/compat.py", line 302, in <module>
    typing_root_type = (typing._Final, typing._GenericAlias)  # type: ignore
AttributeError: 'module' object has no attribute '_GenericAlias'
@guihao-liang guihao-liang added the dependencies Pull requests that update a dependency file label Jan 31, 2020
@guihao-liang
Copy link
Collaborator Author

guihao-liang commented Jan 31, 2020

upgrade hypothesis to latest version 5.4.0, it broke on python3.5.

+ /build/deps/env/bin/python -m pytest -v --durations=100 --junit-xml=../../../../../../../pytest.xml
Traceback (most recent call last):
  File "/build/deps/env/lib/python3.5/site-packages/hypothesis/internal/compat.py", line 78, in <module>
    typing_root_type = (typing._Final, typing._GenericAlias)  # type: ignore
AttributeError: module 'typing' has no attribute '_Final'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.5/runpy.py", line 184, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/build/deps/env/lib/python3.5/site-packages/pytest/__main__.py", line 7, in <module>
    raise SystemExit(pytest.main())
  File "/build/deps/env/lib/python3.5/site-packages/_pytest/config/__init__.py", line 73, in main
    config = _prepareconfig(args, plugins)
  File "/build/deps/env/lib/python3.5/site-packages/_pytest/config/__init__.py", line 224, in _prepareconfig
    pluginmanager=pluginmanager, args=args
  File "/build/deps/env/lib/python3.5/site-packages/pluggy/hooks.py", line 286, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "/build/deps/env/lib/python3.5/site-packages/pluggy/manager.py", line 93, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/build/deps/env/lib/python3.5/site-packages/pluggy/manager.py", line 87, in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
  File "/build/deps/env/lib/python3.5/site-packages/pluggy/callers.py", line 203, in _multicall
    gen.send(outcome)
  File "/build/deps/env/lib/python3.5/site-packages/_pytest/helpconfig.py", line 89, in pytest_cmdline_parse
    config = outcome.get_result()
  File "/build/deps/env/lib/python3.5/site-packages/pluggy/callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/build/deps/env/lib/python3.5/site-packages/pluggy/callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "/build/deps/env/lib/python3.5/site-packages/_pytest/config/__init__.py", line 794, in pytest_cmdline_parse
    self.parse(args)
  File "/build/deps/env/lib/python3.5/site-packages/_pytest/config/__init__.py", line 1000, in parse
    self._preparse(args, addopts=addopts)
  File "/build/deps/env/lib/python3.5/site-packages/_pytest/config/__init__.py", line 948, in _preparse
    self.pluginmanager.load_setuptools_entrypoints("pytest11")
  File "/build/deps/env/lib/python3.5/site-packages/pluggy/manager.py", line 299, in load_setuptools_entrypoints
    plugin = ep.load()
  File "/build/deps/env/lib/python3.5/site-packages/importlib_metadata/__init__.py", line 94, in load
    module = import_module(match.group('module'))
  File "/build/deps/env/lib/python3.5/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 944, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 944, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "/build/deps/env/lib/python3.5/site-packages/_pytest/assertion/rewrite.py", line 143, in exec_module
    exec(co, module.__dict__)
  File "/build/deps/env/lib/python3.5/site-packages/hypothesis/__init__.py", line 24, in <module>
    from hypothesis._settings import HealthCheck, Phase, Verbosity, settings
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "/build/deps/env/lib/python3.5/site-packages/_pytest/assertion/rewrite.py", line 143, in exec_module
    exec(co, module.__dict__)
  File "/build/deps/env/lib/python3.5/site-packages/hypothesis/_settings.py", line 37, in <module>
    from hypothesis.internal.reflection import get_pretty_function_description
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "/build/deps/env/lib/python3.5/site-packages/_pytest/assertion/rewrite.py", line 143, in exec_module
    exec(co, module.__dict__)
  File "/build/deps/env/lib/python3.5/site-packages/hypothesis/internal/reflection.py", line 29, in <module>
    from hypothesis.internal.compat import (
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "/build/deps/env/lib/python3.5/site-packages/_pytest/assertion/rewrite.py", line 143, in exec_module
    exec(co, module.__dict__)
  File "/build/deps/env/lib/python3.5/site-packages/hypothesis/internal/compat.py", line 81, in <module>
    typing_root_type = (typing.TypingMeta, typing.TypeVar, typing._Union)  # type: ignore
AttributeError: module 'typing' has no attribute '_Union'
Uploading artifacts...

even for python35, on Linux.

@guihao-liang
Copy link
Collaborator Author

@guihao-liang
Copy link
Collaborator Author

I can reproduce this on Linux with python3.5. It looks like hypothesis breaks on python3.5 with version 5.x.

Also, hypothesis breaks python2.7 on version 4.26.

@guihao-liang guihao-liang changed the title Pytest is broken on python2.7 Hypothesis is broken on python2.7 and 3.5 Jan 31, 2020
@TobyRoseman
Copy link
Collaborator

@guihao-liang - I'm a little confused when you say: Hypothesis is broken. It's not currently broken in master, right? You're trying to upgrade the version of hypothesis we depend on, and that's breaking?

@guihao-liang
Copy link
Collaborator Author

@guihao-liang - I'm a little confused when you say: Hypothesis is broken. It's not currently broken in master, right? You're trying to upgrade the version of hypothesis we depend on, and that's breaking?

Sorry, let me clarify. The first broken error output is on the master. The second one is from my upgraded one.

@guihao-liang
Copy link
Collaborator Author

@TobyRoseman I realize I'm wrong. The error is introduced by install pre-commit by me. I do pip freeze on master branch and then run pip install pre-commit and pip freeze. I compared the output with the former and later one,

(env) ➜  gui-4-27 git:(master) ✗ diff pre.txt tmp.txt
2d1
< aspy.yaml==1.3.0
10d8
< cfgv==2.0.1
31d28
< identify==1.4.11
34d30
< importlib-resources==1.0.2
43d38
< nodeenv==1.3.4
54d48
< pre-commit==1.21.0
164d157
< PyYAML==5.3
179,180d171
< toml==0.10.0
< typing==3.7.4.1
183d173
< virtualenv==16.7.9

The root cause is introduced by typing==3.7.4.1 which is a known issue for hypothesis.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
dependencies Pull requests that update a dependency file
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants