Skip to content

Try fixing Travis build #666

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

Merged
merged 5 commits into from
Aug 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .flake8-tests
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[flake8]
# fake builtins for python2/*
builtins = basestring, unicode
max-line-length = 90
max-line-length = 100
ignore =
# temporary ignores until we sort it out
E306,
Expand All @@ -18,6 +18,8 @@ ignore =
# irrelevant plugins
B3,
DW12
# consistency with mypy
W504
exclude =
# This config is NOT for the main module.
setup.py
Expand Down
11 changes: 6 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,17 @@ jobs:
python: 3.6.2
- name: "3.6.1"
python: 3.6.1
- name: "3.6.0"
python: 3.6.0
- name: "3.6"
python: 3.6
- name: "3.5.3"
python: 3.5.3
- name: "3.5.2"
python: 3.5.2
- name: "3.5.1"
dist: trusty
python: 3.5.1
- name: "3.5.0"
python: 3.5.0
- name: "3.5"
python: 3.5
- name: "3.4"
python: 3.4
- name: "2.7"
Expand All @@ -42,7 +43,7 @@ install:
script:
- export PYTHONPATH=`python -c "import sys; print('python2' if sys.version.startswith('2') else 'src')"`;
if [[ $TRAVIS_PYTHON_VERSION < '3.7' ]]; then py.test $PYTHONPATH; fi
- if [[ $TRAVIS_PYTHON_VERSION < '3.5' ]]; then python setup.py install; fi
- if [[ $TRAVIS_PYTHON_VERSION < '3.5' ]]; then pip install -U .; fi
- export PYTHONPATH=`python -c "import sys; print('typing_extensions/src_py2' if sys.version.startswith('2') else 'typing_extensions/src_py3')"`;
py.test $PYTHONPATH;
- if [[ $TRAVIS_PYTHON_VERSION == '3.6' ]]; then flake8; fi
Expand Down
11 changes: 5 additions & 6 deletions python2/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1827,7 +1827,6 @@ def __new__(cls, arg):
self.assertEqual(c.from_c, 'c')



class ClassVarTests(BaseTestCase):

def test_basics(self):
Expand Down Expand Up @@ -2308,8 +2307,8 @@ def __len__(self):
self.assertIsSubclass(MMB[str, str], typing.Mapping)
self.assertIsSubclass(MMC, MMA)

class I(typing.Iterable): pass
self.assertNotIsSubclass(list, I)
class It(typing.Iterable): pass
self.assertNotIsSubclass(list, It)

class G(typing.Generator[int, int, int]): pass
def g(): yield 0
Expand Down Expand Up @@ -2366,8 +2365,8 @@ class S(collections.MutableSequence): pass
self.assertIsSubclass(S, typing.MutableSequence)
self.assertIsSubclass(S, typing.Iterable)

class I(collections.Iterable): pass
self.assertIsSubclass(I, typing.Iterable)
class It(collections.Iterable): pass
self.assertIsSubclass(It, typing.Iterable)

class A(collections.Mapping): pass
class B: pass
Expand Down Expand Up @@ -2659,7 +2658,7 @@ def test_respect_no_type_check(self):
class NoTpCheck(object):
class Inn(object):
def __init__(self, x):
# type: (this is not actually a type) -> None
# type: (this is not actually a type) -> None # noqa
pass
self.assertTrue(NoTpCheck.__no_type_check__)
self.assertTrue(NoTpCheck.Inn.__init__.__no_type_check__)
Expand Down
3 changes: 2 additions & 1 deletion python2/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1780,7 +1780,8 @@ def __init__(cls, *args, **kwargs):
if cls._is_protocol:
for base in cls.__mro__[1:]:
if not (base in (object, Generic) or
base.__module__ == '_abcoll' and base.__name__ in _PROTO_WHITELIST or
base.__module__ == '_abcoll' and
base.__name__ in _PROTO_WHITELIST or
isinstance(base, TypingMeta) and base._is_protocol or
isinstance(base, GenericMeta) and base.__origin__ is Generic):
raise TypeError('Protocols can only inherit from other protocols,'
Expand Down
4 changes: 0 additions & 4 deletions src/mod_generics_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@

T = TypeVar('T')


class A(Generic[T]):
some_b: 'B'


class B(Generic[T]):
class A(Generic[T]):
pass
Expand All @@ -35,13 +33,11 @@ class A(Generic[T]):

T = TypeVar('T')


class A(Generic[T]):
__annotations__ = dict(
some_b='B'
)


class B(Generic[T]):
class A(Generic[T]):
pass
Expand Down
26 changes: 13 additions & 13 deletions src/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from typing import TypeVar, AnyStr
from typing import T, KT, VT # Not in __all__.
from typing import Union, Optional
from typing import Tuple, List, MutableMapping
from typing import Tuple, List, MutableMapping, Iterator
from typing import Callable
from typing import Generic, ClassVar, GenericMeta
from typing import cast
Expand Down Expand Up @@ -1539,7 +1539,7 @@ def test_syntax_error(self):

def test_delayed_syntax_error(self):

def foo(a: 'Node[T'):
def foo(a: 'Node[T'): # noqa
pass

with self.assertRaises(SyntaxError):
Expand All @@ -1555,7 +1555,7 @@ def foo(a: Tuple['42']):

def test_name_error(self):

def foo(a: 'Noode[T]'):
def foo(a: 'Noode[T]'): # noqa
pass

with self.assertRaises(NameError):
Expand All @@ -1564,7 +1564,7 @@ def foo(a: 'Noode[T]'):
def test_no_type_check(self):

@no_type_check
def foo(a: 'whatevers') -> {}:
def foo(a: 'whatevers') -> {}: # noqa
pass

th = get_type_hints(foo)
Expand All @@ -1574,7 +1574,7 @@ def test_no_type_check_class(self):

@no_type_check
class C:
def foo(a: 'whatevers') -> {}:
def foo(a: 'whatevers') -> {}: # noqa
pass

cth = get_type_hints(C.foo)
Expand All @@ -1600,12 +1600,12 @@ def magic_decorator(deco):
self.assertEqual(magic_decorator.__name__, 'magic_decorator')

@magic_decorator
def foo(a: 'whatevers') -> {}:
def foo(a: 'whatevers') -> {}: # noqa
pass

@magic_decorator
class C:
def foo(a: 'whatevers') -> {}:
def foo(a: 'whatevers') -> {}: # noqa
pass

self.assertEqual(foo.__name__, 'foo')
Expand Down Expand Up @@ -1764,7 +1764,7 @@ async def g_with(am: AsyncContextManager[int]):
# fake names for the sake of static analysis
ann_module = ann_module2 = ann_module3 = None
A = B = CSub = G = CoolEmployee = CoolEmployeeWithDefault = object
XMeth = XRepr = NoneAndForward = object
XMeth = XRepr = NoneAndForward = HasForeignBaseClass = object

gth = get_type_hints

Expand Down Expand Up @@ -1826,7 +1826,7 @@ def test_respect_no_type_check(self):
@no_type_check
class NoTpCheck:
class Inn:
def __init__(self, x: 'not a type'): ...
def __init__(self, x: 'not a type'): ... # noqa
self.assertTrue(NoTpCheck.__no_type_check__)
self.assertTrue(NoTpCheck.Inn.__init__.__no_type_check__)
self.assertEqual(gth(ann_module2.NTC.meth), {})
Expand Down Expand Up @@ -2233,8 +2233,8 @@ def __len__(self):
self.assertIsSubclass(MMB[str, str], typing.Mapping)
self.assertIsSubclass(MMC, MMA)

class I(typing.Iterable): ...
self.assertNotIsSubclass(list, I)
class It(typing.Iterable): ...
self.assertNotIsSubclass(list, It)

class G(typing.Generator[int, int, int]): ...
def g(): yield 0
Expand Down Expand Up @@ -2316,8 +2316,8 @@ class S(collections_abc.MutableSequence): ...
self.assertIsSubclass(S, typing.MutableSequence)
self.assertIsSubclass(S, typing.Iterable)

class I(collections_abc.Iterable): ...
self.assertIsSubclass(I, typing.Iterable)
class It(collections_abc.Iterable): ...
self.assertIsSubclass(It, typing.Iterable)

class A(collections_abc.Mapping, metaclass=abc.ABCMeta): ...
class B: ...
Expand Down
4 changes: 3 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ ignore =
B3,
DW12,
# code is sometimes better without this
E129
E129,
# consistency with mypy
W504
exclude =
# tests have more relaxed formatting rules
# and its own specific config in .flake8-tests
Expand Down
15 changes: 8 additions & 7 deletions typing_extensions/src_py2/test_typing_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import subprocess
from unittest import TestCase, main

from typing_extensions import Annotated, NoReturn, ClassVar, Final, IntVar, Literal, TypedDict
from typing_extensions import Annotated, NoReturn, ClassVar, IntVar
from typing_extensions import ContextManager, Counter, Deque, DefaultDict
from typing_extensions import NewType, overload
from typing import Dict, List
Expand Down Expand Up @@ -118,15 +118,15 @@ def test_no_isinstance(self):

class IntVarTests(BaseTestCase):
def test_valid(self):
T_ints = IntVar("T_ints")
T_ints = IntVar("T_ints") # noqa

def test_invalid(self):
with self.assertRaises(TypeError):
T_ints = IntVar("T_ints", int)
with self.assertRaises(TypeError):
T_ints = IntVar("T_ints", bound=int)
with self.assertRaises(TypeError):
T_ints = IntVar("T_ints", covariant=True)
T_ints = IntVar("T_ints", covariant=True) # noqa


class CollectionsAbcTests(BaseTestCase):
Expand Down Expand Up @@ -332,8 +332,8 @@ def test_hash_eq(self):

def test_cannot_subclass(self):
with self.assertRaises(TypeError):
class C(Annotated):
pass
class C(Annotated):
pass

def test_cannot_check_instance(self):
with self.assertRaises(TypeError):
Expand Down Expand Up @@ -364,9 +364,9 @@ def test_subst(self):
with self.assertRaises(TypeError):
D[int]

I = Annotated[int, dec]
It = Annotated[int, dec]
with self.assertRaises(TypeError):
I[None]
It[None]

LI = L[int]
with self.assertRaises(TypeError):
Expand All @@ -376,6 +376,7 @@ def test_annotated_in_other_types(self):
X = List[Annotated[T, 5]]
self.assertEqual(X[int], List[Annotated[int, 5]])


class AllTests(BaseTestCase):

def test_typing_extensions_includes_standard(self):
Expand Down
4 changes: 2 additions & 2 deletions typing_extensions/src_py2/typing_extensions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import abc
import sys
import typing
from typing import (
from typing import ( # noqa
# These are imported for re-export.
ClassVar, Type, Generic, Callable, GenericMeta, TypingMeta,
Counter, DefaultDict, Deque, TypeVar, Tuple, Final, final,
NewType, overload, Text, TYPE_CHECKING, Literal, TypedDict, Protocol,
Expand Down
Loading