Skip to content

Commit 4259e37

Browse files
authored
Remove redundant Python 3.7 code (#17004)
Some follow on from #15566. Also add 3.12 to tox.ini.
1 parent c94d8e3 commit 4259e37

File tree

6 files changed

+5
-24
lines changed

6 files changed

+5
-24
lines changed

mypy/modulefinder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,6 @@ def parse_version(version: str) -> tuple[int, int]:
870870

871871
def typeshed_py_version(options: Options) -> tuple[int, int]:
872872
"""Return Python version used for checking whether module supports typeshed."""
873-
# Typeshed no longer covers Python 3.x versions before 3.7, so 3.7 is
873+
# Typeshed no longer covers Python 3.x versions before 3.8, so 3.8 is
874874
# the earliest we can support.
875-
return max(options.python_version, (3, 7))
875+
return max(options.python_version, (3, 8))

mypy/stubgenc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ def get_type_annotation(self, obj: object) -> str:
495495
if obj is None or obj is type(None):
496496
return "None"
497497
elif inspect.isclass(obj):
498-
return "type[{}]".format(self.get_type_fullname(obj))
498+
return f"type[{self.get_type_fullname(obj)}]"
499499
elif isinstance(obj, FunctionType):
500500
return self.add_name("typing.Callable")
501501
elif isinstance(obj, ModuleType):

mypy/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ def _generate_junit_contents(
298298
text=escape("\n".join(messages)),
299299
filename="mypy",
300300
time=dt,
301-
name="mypy-py{ver}-{platform}".format(ver=version, platform=platform),
301+
name=f"mypy-py{version}-{platform}",
302302
)
303303

304304
xml += JUNIT_FOOTER

mypyc/lib-rt/CPy.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -544,13 +544,8 @@ void CPy_AttributeError(const char *filename, const char *funcname, const char *
544544

545545
// Misc operations
546546

547-
#if PY_VERSION_HEX >= 0x03080000
548547
#define CPy_TRASHCAN_BEGIN(op, dealloc) Py_TRASHCAN_BEGIN(op, dealloc)
549548
#define CPy_TRASHCAN_END(op) Py_TRASHCAN_END
550-
#else
551-
#define CPy_TRASHCAN_BEGIN(op, dealloc) Py_TRASHCAN_SAFE_BEGIN(op)
552-
#define CPy_TRASHCAN_END(op) Py_TRASHCAN_SAFE_END(op)
553-
#endif
554549

555550
// Tweaked version of _PyArg_Parser in CPython
556551
typedef struct CPyArg_Parser {

mypyc/lib-rt/pythonsupport.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -354,21 +354,6 @@ list_count(PyListObject *self, PyObject *value)
354354
return CPyTagged_ShortFromSsize_t(count);
355355
}
356356

357-
#if PY_VERSION_HEX < 0x03080000
358-
static PyObject *
359-
_PyDict_GetItemStringWithError(PyObject *v, const char *key)
360-
{
361-
PyObject *kv, *rv;
362-
kv = PyUnicode_FromString(key);
363-
if (kv == NULL) {
364-
return NULL;
365-
}
366-
rv = PyDict_GetItemWithError(v, kv);
367-
Py_DECREF(kv);
368-
return rv;
369-
}
370-
#endif
371-
372357
#define CPyUnicode_EqualToASCIIString(x, y) _PyUnicode_EqualToASCIIString(x, y)
373358

374359
// Adapted from genobject.c in Python 3.7.2

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ envlist =
66
py39,
77
py310,
88
py311,
9+
py312,
910
docs,
1011
lint,
1112
type,

0 commit comments

Comments
 (0)