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

Copy ClassVar upstream #280

Merged
merged 13 commits into from Sep 10, 2016

Conversation

Projects
None yet
2 participants
@ilevkivskyi
Collaborator

ilevkivskyi commented Sep 9, 2016

I added ClassVar to both Python2 and Python3 (and new version of get_type_hints to Python3 version) in a backward compatible manner.

@gvanrossum Please, take a look.

@ilevkivskyi

This comment has been minimized.

Collaborator

ilevkivskyi commented Sep 9, 2016

It looks like tests for 3.6 are failing because they are run on 3.6a4

    x = 5; y: Optional['C'] = None
              ^
SyntaxError: invalid syntax

other tests are OK

@ilevkivskyi

This comment has been minimized.

Collaborator

ilevkivskyi commented Sep 9, 2016

I removed the test modules, anyway they are failing now (SyntaxError), but they will be in 3.6b1 test suite and will work.

@ilevkivskyi ilevkivskyi changed the title from Copy classvar upstream to Copy ClassVar upstream Sep 9, 2016

@@ -5,7 +5,7 @@
import sys
from unittest import TestCase, main, skipUnless, SkipTest
if sys.version_info[:2] >= (3, 6):
import ann_module, ann_module2, ann_module3
from test import ann_module, ann_module2, ann_module3

This comment has been minimized.

@gvanrossum

gvanrossum Sep 9, 2016

Member

Honestly I think this points to a different problem.

The stdlib tests for variable annotations syntax should be moved to a different file altogether (maybe test_annotations.py?). Then we won't need this stuff here. (Also, I really want the text of typing.py and test_typing.py to be identical in Py3.5, Py3.6, and here.)

@gvanrossum

This comment has been minimized.

Member

gvanrossum commented Sep 9, 2016

Regarding the test failure for the 3.6 nightly build, some guesses as to why it fails to import ann_module from test:

  • maybe the nightly build Travis CI uses is only built once a night?
  • maybe it's built using some Debian/Ubuntu build recipe that doesn't include the test package?
  • the SystemError is a known bug in the brand-new compact dict implementation, it will be fixed soon
  • hopefully all these would be solved by moving the annotation syntax tests out of test_typing.py.
@gvanrossum

This comment has been minimized.

Member

gvanrossum commented Sep 9, 2016

Hm, I just looked more carefully and those three modules are imported to test get_type_hints(). I think that can to be done somewhat differently, using the same pattern as used for PY35_TESTS.

@ilevkivskyi

This comment has been minimized.

Collaborator

ilevkivskyi commented Sep 9, 2016

@gvanrossum
I tried to restructure tests a bit. I still get

    exec(PY36_TESTS)
File "<string>", line 6
    x: ClassVar[Optional['B']] = None
      ^
SyntaxError: invalid syntax

I import modules, to check that get_type_hints also works on modules, and to check that it correctly evaluates forward references in namespaces of modules.

@gvanrossum

This comment has been minimized.

Member

gvanrossum commented Sep 9, 2016

Looks like the nightly build doesn't even have PEP 526 support yet... Let's just wait a day.

@gvanrossum

This comment has been minimized.

Member

gvanrossum commented Sep 9, 2016

Can you at least get that test to pass with a 3.6 built from the HEAD locally?

@ilevkivskyi

This comment has been minimized.

Collaborator

ilevkivskyi commented Sep 9, 2016

I just did hg pull and hg checkout tip and I cannot build Python, it returns veeeery long error ending in

Modules/_sre.o:/home/ivan/Devel/hg-cpython/./Modules/sre_lib.h:543: more undefined references to `PyErr_CheckSignals' follow
collect2: error: ld returned 1 exit status
make: *** [Programs/_freeze_importlib] Error 1
@gvanrossum

This comment has been minimized.

Member

gvanrossum commented Sep 9, 2016

try make clean or make clobber?

On Fri, Sep 9, 2016 at 2:28 PM, Ivan Levkivskyi notifications@github.com
wrote:

I just did hg pull and hg checkout tip and I cannot build Python, it
returns veeeery long error ending in

Modules/_sre.o:/home/ivan/Devel/hg-cpython/./Modules/sre_lib.h:543: more undefined references to `PyErr_CheckSignals' follow
collect2: error: ld returned 1 exit status
make: *** [Programs/_freeze_importlib] Error 1


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#280 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/ACwrMmG85aAsptbFWudTgcCv_5BU3h4Kks5qoc9tgaJpZM4J41iV
.

--Guido van Rossum (python.org/~guido)

@gvanrossum

This comment has been minimized.

Member

gvanrossum commented Sep 9, 2016

Or cp Modules/Setup.dist Modules/Setup

On Fri, Sep 9, 2016 at 2:30 PM, Guido van Rossum notifications@github.com
wrote:

try make clean or make clobber?

On Fri, Sep 9, 2016 at 2:28 PM, Ivan Levkivskyi notifications@github.com
wrote:

I just did hg pull and hg checkout tip and I cannot build Python, it
returns veeeery long error ending in

Modules/_sre.o:/home/ivan/Devel/hg-cpython/./Modules/sre_lib.h:543:
more undefined references to `PyErr_CheckSignals' follow
collect2: error: ld returned 1 exit status
make: *** [Programs/_freeze_importlib] Error 1


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#280 (comment), or
mute
the thread
<https://github.com/notifications/unsubscribe-
auth/ACwrMmG85aAsptbFWudTgcCv_5BU3h4Kks5qoc9tgaJpZM4J41iV>
.

--Guido van Rossum (python.org/~guido)


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#280 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/ACwrMsgYaCkTG-8K78AC_tcuw-lQVDKSks5qodADgaJpZM4J41iV
.

--Guido van Rossum (python.org/~guido)

@gvanrossum

This comment has been minimized.

Member

gvanrossum commented Sep 9, 2016

OK, I managed that and get these errors:

======================================================================
ERROR: test_get_type_hints_ClassVar (__main__.GetTypeHintTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test_typing.py", line 1214, in test_get_type_hints_ClassVar
    self.assertEqual(gth(B, locals()),
  File "/Users/guido/src/typing/src/typing.py", line 1296, in get_type_hints
    value = _eval_type(value, globalns, localns)
  File "/Users/guido/src/typing/src/typing.py", line 288, in _eval_type
    return t._eval_type(globalns, localns)
  File "/Users/guido/src/typing/src/typing.py", line 1154, in _eval_type
    return type(self)(_eval_type(self.__type__, globalns, localns),
  File "/Users/guido/src/typing/src/typing.py", line 288, in _eval_type
    return t._eval_type(globalns, localns)
  File "/Users/guido/src/typing/src/typing.py", line 524, in _eval_type
    for t in self.__union_params__)
  File "/Users/guido/src/typing/src/typing.py", line 524, in <genexpr>
    for t in self.__union_params__)
  File "/Users/guido/src/typing/src/typing.py", line 288, in _eval_type
    return t._eval_type(globalns, localns)
  File "/Users/guido/src/typing/src/typing.py", line 175, in _eval_type
    eval(self.__forward_code__, globalns, localns),
  File "<string>", line 1, in <module>
NameError: name 'B' is not defined

----------------------------------------------------------------------
@ilevkivskyi

This comment has been minimized.

Collaborator

ilevkivskyi commented Sep 9, 2016

@gvanrossum
I have fixed this one just replace locals() with globals() (now the class is executed there after refactoring)
But now I get another one
with ChainMap({}, {} ,[}, [}, {}, [})

@ilevkivskyi

This comment has been minimized.

Collaborator

ilevkivskyi commented Sep 9, 2016

@gvanrossum
Also I don't understand where this comes from

======================================================================
ERROR: test_type_optional (test.test_typing.TypeTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/ivan/Devel/hg-cpython/Lib/test/test_typing.py", line 1529, in test_type_optional
    A = Optional[Type[BaseException]]
  File "/home/ivan/Devel/hg-cpython/Lib/typing.py", line 647, in __getitem__
    return Union[arg, type(None)]
  File "/home/ivan/Devel/hg-cpython/Lib/typing.py", line 550, in __getitem__
    dict(self.__dict__), parameters, _root=True)
  File "/home/ivan/Devel/hg-cpython/Lib/typing.py", line 510, in __new__
    for t2 in all_params - {t1} if not isinstance(t2, TypeVar)):
  File "/home/ivan/Devel/hg-cpython/Lib/typing.py", line 510, in <genexpr>
    for t2 in all_params - {t1} if not isinstance(t2, TypeVar)):
  File "/home/ivan/Devel/hg-cpython/Lib/typing.py", line 1075, in __subclasscheck__
    if super().__subclasscheck__(cls):
  File "/home/ivan/Devel/hg-cpython/Lib/abc.py", line 225, in __subclasscheck__
    for scls in cls.__subclasses__():
TypeError: descriptor '__subclasses__' of 'type' object needs an argument
@ilevkivskyi

This comment has been minimized.

Collaborator

ilevkivskyi commented Sep 9, 2016

OK, but the previous version of test_typing still passes!
I need some time to fix the new one.

@gvanrossum

This comment has been minimized.

Member

gvanrossum commented Sep 9, 2016

Do you need more help?

@ilevkivskyi

This comment has been minimized.

Collaborator

ilevkivskyi commented Sep 9, 2016

I will try to fix it, and if will not manage within 30 minutes, then I will ask for help :-)

Thanks!

@ilevkivskyi

This comment has been minimized.

Collaborator

ilevkivskyi commented Sep 9, 2016

@gvanrossum

I have fixed all tests locally, the most important fix was to also copy typing to hg tip that means that python/typing is ahead and here are some changes that are not integrated in master hg repo.

The easiest fix would be to just copy what we have here (both typing and test_typing) to master hg repo. Could you please do this (of course if you are satisfied with the PR)?

@gvanrossum

This comment has been minimized.

Member

gvanrossum commented Sep 9, 2016

Yay! It works! I'll wait to merge until the nightly build has variable annotations. I also want to port this to the cpython repo.

@ilevkivskyi

This comment has been minimized.

Collaborator

ilevkivskyi commented Sep 10, 2016

@gvanrossum
I pushed an empty commit to trigger Travis, it looks like all green now.

@gvanrossum gvanrossum merged commit 2dd068b into python:master Sep 10, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@gvanrossum

This comment has been minimized.

Member

gvanrossum commented Sep 10, 2016

Thanks!!

@dotlambda dotlambda referenced this pull request Feb 3, 2018

Merged

Python package updates #34553

0 of 8 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment