Closed jabdoa2 closed 6 years ago
Can't repro. ~Also your first sentence is~
Sorry. Fixed that. Just bisected it. It starts crashing with this commit: https://github.com/dropbox/pyannotate/commit/01980b3ad607dd5a89c35a42226472b92ebbda65.
This is another PC with Ubuntu 16.04 and Python 3.5.2.
Weird. Do you see anything in that commit that could have a bearing on logging initialization? I guess the most likely culprit is the added package typing_extensions. Could you try changing all the places where it says from typing_extensions import Text
to from typing import Text
? If that fixes it we know it's something in that module.
Also does the contents of type_info.json matter? Or does it still crash when that's just []
? And what's the output of pip list
?
Maybe @ilevkivskyi has any ideas?
It works if I revert the occurrences of typing_extensions to typing.
The content of type_info.json does not matter. Also crashes if it is just []
.
pip:
pip3 list
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
alabaster (0.7.10)
apigpio (0.0.1, /data/home/jan/cloud/flipper/src/apigpio)
appdirs (1.4.3)
apt-clone (0.2.1)
apt-xapian-index (0.47)
asciimatics (1.8.0)
astroid (1.5.3)
asyncio (3.4.3)
Babel (2.4.0)
beautifulsoup4 (4.4.1)
chardet (2.3.0)
command-not-found (0.3)
coverage (4.2)
Cython (0.23.1)
defer (1.0.6)
devscripts (2.16.2ubuntu3)
docutils (0.13.1)
dodgy (0.1.9)
future (0.16.0)
gitdb2 (2.0.2)
GitPython (2.1.5)
html5lib (0.999)
imagesize (0.7.1)
isort (4.2.15)
Jinja2 (2.9.6)
Kivy (1.10.0)
Kivy-Garden (0.1.4)
language-selector (0.1)
lazy-object-proxy (1.3.1)
lightdm-gtk-greeter-settings (1.2.1)
logilab-common (1.2.2)
lxml (3.5.0)
Magic-file-extensions (0.2)
MarkupSafe (1.0)
mccabe (0.6.1)
mock (2.0.0)
mpf (0.50.0.dev27, /data/home/jan/cloud/flipper/src/mpf)
mpf-mc (0.50.0.dev11, /data/home/jan/cloud/flipper/src/mpf-mc)
mpf-monitor (0.1.8, /data/home/jan/cloud/flipper/src/mpf-monitor)
mpmath (0.19)
mypy (0.540)
mypy-extensions (0.3.0)
olefile (0.44)
packaging (16.8)
PAM (0.4.2)
pbr (1.10.0)
pep8-naming (0.4.1)
Pillow (4.3.0)
pip (9.0.1)
prospector (0.12.7)
psutil (5.2.0)
pyannotate (1.0.2, /data/home/jan/cloud/flipper/src/pyannotate)
pycodestyle (2.0.0)
pycups (1.9.73)
pycurl (7.43.0)
pydocstyle (2.0.0)
pyfiglet (0.7.5)
pyflakes (1.6.0)
Pygments (2.2.0)
pygobject (3.20.0)
PyICU (1.9.2)
pylint (1.7.4)
pylint-celery (0.3)
pylint-common (0.2.5)
pylint-django (0.7.2)
pylint-flask (0.5)
pylint-plugin-utils (0.2.6)
pyparsing (2.2.0)
PyQt5 (5.7)
pyserial (3.3)
pyserial-asyncio (0.4, /data/home/jan/cloud/flipper/src/pyserial-asyncio)
python-afl (0.6)
python-apt (1.1.0b1)
python-debian (0.1.27)
python-systemd (231)
pytz (2017.2)
PyYAML (3.12)
requests (2.9.1)
requirements-detector (0.5.2)
ruamel.base (1.0.0)
ruamel.yaml (0.10.23)
setoptconf (0.2.0)
setuptools (35.0.2)
SimpleParse (2.2.0)
sip (4.18.1)
six (1.11.0)
smmap2 (2.0.3)
snowballstemmer (1.2.1)
Sphinx (1.6.3)
sphinx-rtd-theme (0.2.4)
sphinxcontrib-websupport (1.0.1)
ssh-import-id (5.5)
sympy (1.0)
typed-ast (1.1.0)
typing (3.6.2)
typing-extensions (3.6.2.1)
ubuntu-drivers-common (0.0.0)
ufw (0.35)
unattended-upgrades (0.1)
unittest-data-provider (1.0.1)
urllib3 (1.13.1)
usb-creator (0.3.0)
uvloop (0.8.1)
wcwidth (0.1.7)
wheel (0.29.0)
wrapt (1.10.11)
xkit (0.0.0)
I wonder if a much simpler program that just tries to initialize logging (but imports typing_extensions first) would also crash.
It is clear that the actual "problematic" line is isinstance(args[0], collections.Mapping)
. I think I understand why the crash happens, but I am not sure yet how to fix it in typing_extensions
. The problem is that old version of typing
calls issubclass(cls, self.__extra__)
even if the latter is an ABC that will return to the same class via __subclasses__
. This can be (and already is) fixed in recent typing
.
A possible solution for typing_extensions
is to define a custom metaclass inheriting from GenericMeta
that will override __subclasscheck__
. This could fix the issue, @jabdoa2 could you please open an issue on https://github.com/python/typing/issues?
In the meantime I think I'll drop the typing_extensions dependency from pyannotate for now.
Works fine on v1.0.2. On head this crashes: