Skip to content

Commit 71fbbab

Browse files
Merge branch 'master' into fix/17870
2 parents a846aff + 740292a commit 71fbbab

File tree

11 files changed

+52
-63
lines changed

11 files changed

+52
-63
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ repos:
66
- id: trailing-whitespace
77
- id: end-of-file-fixer
88
- repo: https://github.com/psf/black-pre-commit-mirror
9-
rev: 24.1.1 # must match test-requirements.txt
9+
rev: 24.8.0 # must match test-requirements.txt
1010
hooks:
1111
- id: black
1212
exclude: '^(test-data/)'
1313
- repo: https://github.com/astral-sh/ruff-pre-commit
14-
rev: v0.2.0 # must match test-requirements.txt
14+
rev: v0.6.9 # must match test-requirements.txt
1515
hooks:
1616
- id: ruff
1717
args: [--exit-non-zero-on-fix]

mypy/fastparse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2033,7 +2033,7 @@ def visit_UnaryOp(self, n: UnaryOp) -> Type:
20332033
if (
20342034
isinstance(typ, RawExpressionType)
20352035
# Use type() because we do not want to allow bools.
2036-
and type(typ.literal_value) is int # noqa: E721
2036+
and type(typ.literal_value) is int
20372037
):
20382038
if isinstance(n.op, USub):
20392039
typ.literal_value *= -1

mypy/ipc.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@
1717

1818
if sys.platform == "win32":
1919
# This may be private, but it is needed for IPC on Windows, and is basically stable
20-
import ctypes
21-
2220
import _winapi
21+
import ctypes
2322

2423
_IPCHandle = int
2524

mypy/server/astmerge.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def replacement_map_from_symbol_table(
160160
):
161161
new_node = new[name]
162162
if (
163-
type(new_node.node) == type(node.node) # noqa: E721
163+
type(new_node.node) == type(node.node)
164164
and new_node.node
165165
and node.node
166166
and new_node.node.fullname == node.node.fullname

mypy/stubtest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ def _verify_arg_default_value(
700700
stub_default != runtime_arg.default
701701
# We want the types to match exactly, e.g. in case the stub has
702702
# True and the runtime has 1 (or vice versa).
703-
or type(stub_default) is not type(runtime_arg.default) # noqa: E721
703+
or type(stub_default) is not type(runtime_arg.default)
704704
)
705705
):
706706
yield (

mypy/util.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@
1515
from typing_extensions import Literal
1616

1717
try:
18-
import curses
19-
2018
import _curses # noqa: F401
19+
import curses
2120

2221
CURSES_ENABLED = True
2322
except ImportError:

mypyc/lib-rt/pythoncapi_compat.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,7 +1537,7 @@ static inline int PyUnicode_Equal(PyObject *str1, PyObject *str2)
15371537
}
15381538

15391539
#if PY_VERSION_HEX >= 0x030d0000 && !defined(PYPY_VERSION)
1540-
extern int _PyUnicode_Equal(PyObject *str1, PyObject *str2);
1540+
PyAPI_FUNC(int) _PyUnicode_Equal(PyObject *str1, PyObject *str2);
15411541

15421542
return _PyUnicode_Equal(str1, str2);
15431543
#elif PY_VERSION_HEX >= 0x03060000 && !defined(PYPY_VERSION)
@@ -1564,7 +1564,7 @@ static inline PyObject* PyBytes_Join(PyObject *sep, PyObject *iterable)
15641564
static inline Py_hash_t Py_HashBuffer(const void *ptr, Py_ssize_t len)
15651565
{
15661566
#if PY_VERSION_HEX >= 0x03000000 && !defined(PYPY_VERSION)
1567-
extern Py_hash_t _Py_HashBytes(const void *src, Py_ssize_t len);
1567+
PyAPI_FUNC(Py_hash_t) _Py_HashBytes(const void *src, Py_ssize_t len);
15681568

15691569
return _Py_HashBytes(ptr, len);
15701570
#else

mypyc/lib-rt/pythonsupport.h

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -402,45 +402,15 @@ _CPyObject_HasAttrId(PyObject *v, _Py_Identifier *name) {
402402
PyObject_CallMethodObjArgs((self), (name), (arg), NULL)
403403
#endif
404404

405-
#if CPY_3_13_FEATURES
406-
407-
// These are copied from genobject.c in Python 3.13
408-
409-
/* Returns a borrowed reference */
410-
static inline PyCodeObject *
411-
_PyGen_GetCode(PyGenObject *gen) {
412-
_PyInterpreterFrame *frame = (_PyInterpreterFrame *)(gen->gi_iframe);
413-
return _PyFrame_GetCode(frame);
414-
}
415-
416-
static int
417-
gen_is_coroutine(PyObject *o)
418-
{
419-
if (PyGen_CheckExact(o)) {
420-
PyCodeObject *code = _PyGen_GetCode((PyGenObject*)o);
421-
if (code->co_flags & CO_ITERABLE_COROUTINE) {
422-
return 1;
423-
}
424-
}
425-
return 0;
426-
}
427-
428-
#elif CPY_3_12_FEATURES
405+
#if CPY_3_12_FEATURES
429406

430407
// These are copied from genobject.c in Python 3.12
431408

432-
/* Returns a borrowed reference */
433-
static inline PyCodeObject *
434-
_PyGen_GetCode(PyGenObject *gen) {
435-
_PyInterpreterFrame *frame = (_PyInterpreterFrame *)(gen->gi_iframe);
436-
return frame->f_code;
437-
}
438-
439409
static int
440410
gen_is_coroutine(PyObject *o)
441411
{
442412
if (PyGen_CheckExact(o)) {
443-
PyCodeObject *code = _PyGen_GetCode((PyGenObject*)o);
413+
PyCodeObject *code = PyGen_GetCode((PyGenObject*)o);
444414
if (code->co_flags & CO_ITERABLE_COROUTINE) {
445415
return 1;
446416
}

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,10 @@ ignore = [
6666
"E2", # conflicts with black
6767
"E402", # module level import not at top of file
6868
"E501", # conflicts with black
69+
"E721", # Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
6970
"E731", # Do not assign a `lambda` expression, use a `def`
7071
"E741", # Ambiguous variable name
72+
"UP031", # Use format specifiers instead of percent format
7173
"UP032", # 'f-string always preferable to format' is controversial
7274
"C416", # There are a few cases where it's nice to have names for the dict items
7375
]

test-requirements.in

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
-r mypy-requirements.txt
55
-r build-requirements.txt
66
attrs>=18.0
7-
black==24.3.0 # must match version in .pre-commit-config.yaml
7+
black==24.8.0 # must match version in .pre-commit-config.yaml
88
filelock>=3.3.0
99
# lxml 4.9.3 switched to manylinux_2_28, the wheel builder still uses manylinux2014
1010
lxml>=4.9.1,<4.9.3; (python_version<'3.11' or sys_platform!='win32') and python_version<'3.12'
1111
psutil>=4.0
1212
pytest>=8.1.0
1313
pytest-xdist>=1.34.0
1414
pytest-cov>=2.10.0
15-
ruff==0.2.0 # must match version in .pre-commit-config.yaml
15+
ruff==0.6.9 # must match version in .pre-commit-config.yaml
1616
setuptools>=65.5.1
1717
tomli>=1.1.0 # needed even on py311+ so the self check passes with --python-version 3.8
18+
pre_commit>=3.5.0

0 commit comments

Comments
 (0)