Merge pull request #5415 from asottile/small_mypy_fixes

small mypy fixes
This commit is contained in:
Anthony Sottile 2019-06-06 10:47:58 -07:00 committed by GitHub
commit 0405697a78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 8 additions and 21 deletions

View File

@ -81,19 +81,12 @@ def _format_lines(lines):
return result
# Provide basestring in python3
try:
basestring = basestring
except NameError:
basestring = str
def issequence(x):
return isinstance(x, Sequence) and not isinstance(x, basestring)
return isinstance(x, Sequence) and not isinstance(x, str)
def istext(x):
return isinstance(x, basestring)
return isinstance(x, str)
def isdict(x):

View File

@ -114,7 +114,7 @@ def fail(msg="", pytrace=True):
fail.Exception = Failed
class XFailed(fail.Exception):
class XFailed(Failed):
""" raised from an explicit call to pytest.xfail() """

View File

@ -15,7 +15,7 @@ def test_maxsize():
def test_maxsize_error_on_instance():
class A:
def __repr__():
def __repr__(self):
raise ValueError("...")
s = saferepr(("*" * 50, A()), maxsize=25)

View File

@ -26,10 +26,10 @@ def test_getfuncargnames():
assert fixtures.getfuncargnames(h) == ("arg1",)
def h(arg1, arg2, arg3="hello"):
def j(arg1, arg2, arg3="hello"):
pass
assert fixtures.getfuncargnames(h) == ("arg1", "arg2")
assert fixtures.getfuncargnames(j) == ("arg1", "arg2")
class A:
def f(self, arg1, arg2="hello"):

View File

@ -235,7 +235,7 @@ class TestRaises:
int("asdf")
def test_raises_exception_looks_iterable(self):
class Meta(type(object)):
class Meta(type):
def __getitem__(self, item):
return 1 / 0

View File

@ -189,12 +189,7 @@ def test_hookrecorder_basic(holder):
def test_makepyfile_unicode(testdir):
global unichr
try:
unichr(65)
except NameError:
unichr = chr
testdir.makepyfile(unichr(0xFFFD))
testdir.makepyfile(chr(0xFFFD))
def test_makepyfile_utf8(testdir):

View File

@ -24,7 +24,6 @@ def test_ensuretemp(recwarn):
@attr.s
class FakeConfig:
basetemp = attr.ib()
trace = attr.ib(default=None)
@property
def trace(self):