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

The result of format_annotation() has been changed with python 3.7.0a4+ #4490

Closed
tk0miya opened this issue Jan 24, 2018 · 3 comments
Closed

Comments

@tk0miya
Copy link
Member

tk0miya commented Jan 24, 2018

Problem

  • The result of format_annotation() has been changed with python 3.7.0a4+.

Procedure to reproduce the problem

  • Run tests of Sphinx with python 3.7.0a4+

Error logs / results

https://travis-ci.org/sphinx-doc/sphinx/jobs/332762559#L2003

@tk0miya
Copy link
Member Author

tk0miya commented Jan 24, 2018

Since py370a4+, the implementation of typing module has been changed (ref: python/cpython#4906)

$ python3.6
Python 3.6.4 (default, Dec 20 2017, 01:09:24)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import typing
>>> isinstance(typing.List, type)
True
>>> typing.GenericMeta
<class 'typing.GenericMeta'>
>>> typing.CallableMeta
<class 'typing.CallableMeta'>
$ python3.7
Python 3.7.0a4+ (heads/master:131fd7f, Jan 24 2018, 23:03:18)
[Clang 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import typing
>>> isinstance(typing.List, type)
False
>>> typing.GenericMeta
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'typing' has no attribute 'GenericMeta'
>>> typing.CallableMeta
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'typing' has no attribute 'CallableMeta'

For this reason, the result of format_annotation() has been changed.

>       assert formatargspec(f, *getargspec(f)) == expected
E       AssertionError: assert '(x: typing.L...st[-T_contra]' == '(x: typing.Li...ist[T_contra]'
E         - (x: typing.List[~T], y: typing.List[+T_co], z: T) -> typing.List[-T_contra]
E         ?                 -                   -                            -
E         + (x: typing.List[T], y: typing.List[T_co], z: T) -> typing.List[T_contra]

There are +, - and ~ prefix on annotation.

@tk0miya
Copy link
Member Author

tk0miya commented Jan 24, 2018

Note: I just pushed workarounds for this; #4488 and #4489 to pass test cases temporarily.

@tk0miya tk0miya changed the title The result of format_annotation() has been changed in python 3.7.0a4+ The result of format_annotation() has been changed with python 3.7.0a4+ Jan 24, 2018
tk0miya added a commit to tk0miya/sphinx that referenced this issue Jan 27, 2018
tk0miya added a commit to tk0miya/sphinx that referenced this issue Jan 27, 2018
tk0miya added a commit that referenced this issue Jan 27, 2018
Fix #4490: autodoc: type annotation is broken with python 3.7.0a4+
@tk0miya
Copy link
Member Author

tk0miya commented Jan 27, 2018

Fixed by #4502

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant