Skip to content

Commit

Permalink
Remove redundant Python 3.7 code (#17004)
Browse files Browse the repository at this point in the history

Some follow on from #15566.

Also add 3.12 to tox.ini.
  • Loading branch information
hugovk committed Mar 9, 2024
1 parent c94d8e3 commit 4259e37
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 24 deletions.
4 changes: 2 additions & 2 deletions mypy/modulefinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,6 @@ def parse_version(version: str) -> tuple[int, int]:

def typeshed_py_version(options: Options) -> tuple[int, int]:
"""Return Python version used for checking whether module supports typeshed."""
# Typeshed no longer covers Python 3.x versions before 3.7, so 3.7 is
# Typeshed no longer covers Python 3.x versions before 3.8, so 3.8 is
# the earliest we can support.
return max(options.python_version, (3, 7))
return max(options.python_version, (3, 8))
2 changes: 1 addition & 1 deletion mypy/stubgenc.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ def get_type_annotation(self, obj: object) -> str:
if obj is None or obj is type(None):
return "None"
elif inspect.isclass(obj):
return "type[{}]".format(self.get_type_fullname(obj))
return f"type[{self.get_type_fullname(obj)}]"
elif isinstance(obj, FunctionType):
return self.add_name("typing.Callable")
elif isinstance(obj, ModuleType):
Expand Down
2 changes: 1 addition & 1 deletion mypy/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def _generate_junit_contents(
text=escape("\n".join(messages)),
filename="mypy",
time=dt,
name="mypy-py{ver}-{platform}".format(ver=version, platform=platform),
name=f"mypy-py{version}-{platform}",
)

xml += JUNIT_FOOTER
Expand Down
5 changes: 0 additions & 5 deletions mypyc/lib-rt/CPy.h
Original file line number Diff line number Diff line change
Expand Up @@ -544,13 +544,8 @@ void CPy_AttributeError(const char *filename, const char *funcname, const char *

// Misc operations

#if PY_VERSION_HEX >= 0x03080000
#define CPy_TRASHCAN_BEGIN(op, dealloc) Py_TRASHCAN_BEGIN(op, dealloc)
#define CPy_TRASHCAN_END(op) Py_TRASHCAN_END
#else
#define CPy_TRASHCAN_BEGIN(op, dealloc) Py_TRASHCAN_SAFE_BEGIN(op)
#define CPy_TRASHCAN_END(op) Py_TRASHCAN_SAFE_END(op)
#endif

// Tweaked version of _PyArg_Parser in CPython
typedef struct CPyArg_Parser {
Expand Down
15 changes: 0 additions & 15 deletions mypyc/lib-rt/pythonsupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -354,21 +354,6 @@ list_count(PyListObject *self, PyObject *value)
return CPyTagged_ShortFromSsize_t(count);
}

#if PY_VERSION_HEX < 0x03080000
static PyObject *
_PyDict_GetItemStringWithError(PyObject *v, const char *key)
{
PyObject *kv, *rv;
kv = PyUnicode_FromString(key);
if (kv == NULL) {
return NULL;
}
rv = PyDict_GetItemWithError(v, kv);
Py_DECREF(kv);
return rv;
}
#endif

#define CPyUnicode_EqualToASCIIString(x, y) _PyUnicode_EqualToASCIIString(x, y)

// Adapted from genobject.c in Python 3.7.2
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ envlist =
py39,
py310,
py311,
py312,
docs,
lint,
type,
Expand Down

0 comments on commit 4259e37

Please sign in to comment.