Skip to content

Commit a1c9eb2

Browse files
committed
Uncomment code in typing
1 parent 37dbf6f commit a1c9eb2

4 files changed

Lines changed: 34 additions & 27 deletions

File tree

src/core/IronPython.StdLib/lib/test/test_typing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
from test import mod_generics_cache
3838

3939

40-
PY36 = sys.version_info[:2] >= (3, 6) and not sys.implementation.name == 'ironpython' # https://github.com/IronLanguages/ironpython3/issues/98
40+
PY36 = sys.version_info[:2] >= (3, 6)
4141

4242

4343
class BaseTestCase(TestCase):
@@ -1647,7 +1647,7 @@ def blah():
16471647
blah()
16481648

16491649

1650-
ASYNCIO = sys.version_info[:2] >= (3, 5) and not sys.implementation.name == 'ironpython' # https://github.com/IronLanguages/ironpython3/issues/98
1650+
ASYNCIO = sys.version_info[:2] >= (3, 5)
16511651

16521652
ASYNCIO_TESTS = """
16531653
import asyncio

src/core/IronPython.StdLib/lib/typing.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1975,30 +1975,30 @@ class AsyncContextManager(Generic[T_co],
19751975
__slots__ = ()
19761976

19771977
__all__.append('AsyncContextManager')
1978-
#elif sys.version_info[:2] >= (3, 5):
1979-
# exec("""
1980-
#class AsyncContextManager(Generic[T_co]):
1981-
# __slots__ = ()
1982-
#
1983-
# async def __aenter__(self):
1984-
# return self
1985-
#
1986-
# @abc.abstractmethod
1987-
# async def __aexit__(self, exc_type, exc_value, traceback):
1988-
# return None
1989-
#
1990-
# @classmethod
1991-
# def __subclasshook__(cls, C):
1992-
# if cls is AsyncContextManager:
1993-
# if sys.version_info[:2] >= (3, 6):
1994-
# return _collections_abc._check_methods(C, "__aenter__", "__aexit__")
1995-
# if (any("__aenter__" in B.__dict__ for B in C.__mro__) and
1996-
# any("__aexit__" in B.__dict__ for B in C.__mro__)):
1997-
# return True
1998-
# return NotImplemented
1999-
#
2000-
#__all__.append('AsyncContextManager')
2001-
#""")
1978+
elif sys.version_info[:2] >= (3, 5):
1979+
exec("""
1980+
class AsyncContextManager(Generic[T_co]):
1981+
__slots__ = ()
1982+
1983+
async def __aenter__(self):
1984+
return self
1985+
1986+
@abc.abstractmethod
1987+
async def __aexit__(self, exc_type, exc_value, traceback):
1988+
return None
1989+
1990+
@classmethod
1991+
def __subclasshook__(cls, C):
1992+
if cls is AsyncContextManager:
1993+
if sys.version_info[:2] >= (3, 6):
1994+
return _collections_abc._check_methods(C, "__aenter__", "__aexit__")
1995+
if (any("__aenter__" in B.__dict__ for B in C.__mro__) and
1996+
any("__aexit__" in B.__dict__ for B in C.__mro__)):
1997+
return True
1998+
return NotImplemented
1999+
2000+
__all__.append('AsyncContextManager')
2001+
""")
20022002

20032003

20042004
class Dict(dict, MutableMapping[KT, VT], extra=dict):

src/core/IronPython/Compiler/Parser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1457,8 +1457,8 @@ private WithItem ParseWithItem() {
14571457

14581458
// async_stmt: 'async' (funcdef | with_stmt | for_stmt)
14591459
private Statement ParseAsyncStmt() {
1460-
var start = GetStart();
14611460
Eat(TokenKind.KeywordAsync);
1461+
var start = GetStart();
14621462

14631463
switch (PeekToken().Kind) {
14641464
case TokenKind.KeywordDef:

tests/suite/test_typing_stdlib.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,17 @@ def load_tests(loader, standard_tests, pattern):
1616
if is_ironpython:
1717
failing_tests = [
1818
test.test_typing.GenericTests('test_generic_hashes'), # https://github.com/IronLanguages/ironpython3/issues/30
19+
test.test_typing.GenericTests('test_init_subclass'), # AttributeError: 'GenericMeta' object has no attribute 'attr'
1920
test.test_typing.GenericTests('test_repr_2'), # https://github.com/IronLanguages/ironpython3/issues/30
2021
test.test_typing.GenericTests('test_parameterized_slots_dict'), # TypeError: slots must be one string or a list of strings
2122
test.test_typing.GenericTests('test_type_erasure_special'), # TypeError: Parameterized Tuple cannot be used with isinstance().
23+
test.test_typing.GetTypeHintTests('test_get_type_hints_ClassVar'), # AssertionError
24+
test.test_typing.GetTypeHintTests('test_get_type_hints_classes'), # AssertionError
25+
test.test_typing.GetTypeHintTests('test_get_type_hints_modules'), # AssertionError
2226
test.test_typing.IOTests('test_io_submodule'), # ImportError: Cannot import name __name__
27+
test.test_typing.NamedTupleTests('test_annotation_usage'), # TypeError: __new__() takes exactly 1 argument (3 given)
28+
test.test_typing.NamedTupleTests('test_annotation_usage_with_default'), # TypeError: __new__() takes exactly 1 argument (2 given)
29+
test.test_typing.NamedTupleTests('test_annotation_usage_with_methods'), # TypeError: __new__() takes exactly 1 argument (2 given)
2330
test.test_typing.RETests('test_basics'), # TypeError: issubclass(): _TypeAlias is not a class nor a tuple of classes
2431
test.test_typing.RETests('test_cannot_subclass'), # AssertionError
2532
test.test_typing.RETests('test_re_submodule'), # ImportError: Cannot import name __name__

0 commit comments

Comments
 (0)