Skip to content
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

Remove redundant Python 3.7 code #17004

Merged
merged 3 commits into from
Mar 9, 2024
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: 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
Loading