Skip to content

Commit a73498a

Browse files
authored
Merge pull request #30002 from rwgk/pywrapcc_merge_sh_202302222227
git merge smart_holder
2 parents fbb624c + aec76e0 commit a73498a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+328
-333
lines changed

.pre-commit-config.yaml

Lines changed: 6 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,6 @@ repos:
4040
- id: trailing-whitespace
4141
exclude: \.patch?$
4242

43-
# Upgrade old Python syntax
44-
- repo: https://github.com/asottile/pyupgrade
45-
rev: "v3.3.1"
46-
hooks:
47-
- id: pyupgrade
48-
args: [--py36-plus]
49-
50-
# Nicely sort includes
51-
- repo: https://github.com/PyCQA/isort
52-
rev: "5.12.0"
53-
hooks:
54-
- id: isort
55-
5643
# Black, the code formatter, natively supports pre-commit
5744
- repo: https://github.com/psf/black
5845
rev: "23.1.0" # Keep in sync with blacken-docs
@@ -74,49 +61,28 @@ repos:
7461
- id: remove-tabs
7562
exclude: (^docs/.*|\.patch)?$
7663

64+
# Avoid directional quotes
7765
- repo: https://github.com/sirosen/texthooks
7866
rev: "0.5.0"
7967
hooks:
8068
- id: fix-ligatures
8169
- id: fix-smartquotes
8270

83-
# Autoremoves unused imports
84-
- repo: https://github.com/hadialqattan/pycln
85-
rev: "v2.1.3"
71+
# Ruff, the Python auto-correcting linter written in Rust
72+
- repo: https://github.com/charliermarsh/ruff-pre-commit
73+
rev: v0.0.251
8674
hooks:
87-
- id: pycln
88-
stages: [manual]
75+
- id: ruff
76+
args: ["--fix", "--show-fixes"]
8977

9078
# Checking for common mistakes
9179
- repo: https://github.com/pre-commit/pygrep-hooks
9280
rev: "v1.10.0"
9381
hooks:
94-
- id: python-check-blanket-noqa
95-
- id: python-check-blanket-type-ignore
96-
exclude: ubench/holder_comparison.py
97-
- id: python-no-log-warn
98-
- id: python-use-type-annotations
9982
- id: rst-backticks
10083
- id: rst-directive-colons
10184
- id: rst-inline-touching-normal
10285

103-
# Automatically remove noqa that are not used
104-
- repo: https://github.com/asottile/yesqa
105-
rev: "v1.4.0"
106-
hooks:
107-
- id: yesqa
108-
additional_dependencies: &flake8_dependencies
109-
- flake8-bugbear
110-
- pep8-naming
111-
112-
# Flake8 also supports pre-commit natively (same author)
113-
- repo: https://github.com/PyCQA/flake8
114-
rev: "6.0.0"
115-
hooks:
116-
- id: flake8
117-
exclude: ^(docs/.*|tools/.*|ubench/.*)$
118-
additional_dependencies: *flake8_dependencies
119-
12086
# PyLint has native support - not always usable, but works for us
12187
- repo: https://github.com/PyCQA/pylint
12288
rev: "v2.16.1"

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ def prepare(app):
353353
f.write(contents)
354354

355355

356-
def clean_up(app, exception):
356+
def clean_up(app, exception): # noqa: ARG001
357357
(DIR / "readme.rst").unlink()
358358

359359

include/pybind11/eigen/matrix.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
PYBIND11_WARNING_PUSH
2020
PYBIND11_WARNING_DISABLE_MSVC(5054) // https://github.com/pybind/pybind11/pull/3741
2121
// C5054: operator '&': deprecated between enumerations of different types
22+
#if defined(__MINGW32__)
2223
PYBIND11_WARNING_DISABLE_GCC("-Wmaybe-uninitialized")
24+
#endif
2325

2426
#include <Eigen/Core>
2527
#include <Eigen/SparseCore>

include/pybind11/eigen/tensor.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ static_assert(__GNUC__ > 5, "Eigen Tensor support in pybind11 requires GCC > 5.0
1717
PYBIND11_WARNING_PUSH
1818
PYBIND11_WARNING_DISABLE_MSVC(4554)
1919
PYBIND11_WARNING_DISABLE_MSVC(4127)
20+
#if defined(__MINGW32__)
2021
PYBIND11_WARNING_DISABLE_GCC("-Wmaybe-uninitialized")
22+
#endif
2123

2224
#include <unsupported/Eigen/CXX11/Tensor>
2325

include/pybind11/numpy.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,10 +1121,10 @@ class array_t : public array {
11211121

11221122
/**
11231123
* Returns a proxy object that provides const access to the array's data without bounds or
1124-
* dimensionality checking. Unlike `unchecked()`, this does not require that the underlying
1125-
* array have the `writable` flag. Use with care: the array must not be destroyed or reshaped
1126-
* for the duration of the returned object, and the caller must take care not to access invalid
1127-
* dimensions or dimension indices.
1124+
* dimensionality checking. Unlike `mutable_unchecked()`, this does not require that the
1125+
* underlying array have the `writable` flag. Use with care: the array must not be destroyed
1126+
* or reshaped for the duration of the returned object, and the caller must take care not to
1127+
* access invalid dimensions or dimension indices.
11281128
*/
11291129
template <ssize_t Dims = -1>
11301130
detail::unchecked_reference<T, Dims> unchecked() const & {

pybind11/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import sys
22

3-
if sys.version_info < (3, 6):
3+
if sys.version_info < (3, 6): # noqa: UP036
44
msg = "pybind11 does not support Python < 3.6. 2.9 was the last release supporting Python 2.7 and 3.5."
55
raise ImportError(msg)
66

pybind11/commands.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
DIR = os.path.abspath(os.path.dirname(__file__))
44

55

6-
def get_include(user: bool = False) -> str: # pylint: disable=unused-argument
6+
def get_include(user: bool = False) -> str: # noqa: ARG001
77
"""
88
Return the path to the pybind11 include directory. The historical "user"
99
argument is unused, and may be removed.

pybind11/setup_helpers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def cxx_std(self) -> int:
175175
def cxx_std(self, level: int) -> None:
176176
if self._cxx_level:
177177
warnings.warn(
178-
"You cannot safely change the cxx_level after setting it!", stacklevel=1
178+
"You cannot safely change the cxx_level after setting it!", stacklevel=2
179179
)
180180

181181
# MSVC 2015 Update 3 and later only have 14 (and later 17) modes, so
@@ -341,7 +341,7 @@ def naive_recompile(obj: str, src: str) -> bool:
341341
return os.stat(obj).st_mtime < os.stat(src).st_mtime
342342

343343

344-
def no_recompile(obg: str, src: str) -> bool: # pylint: disable=unused-argument
344+
def no_recompile(obg: str, src: str) -> bool: # noqa: ARG001
345345
"""
346346
This is the safest but slowest choice (and is the default) - will always
347347
recompile sources.

pyproject.toml

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,6 @@ ignore = [
1515
"noxfile.py",
1616
]
1717

18-
[tool.isort]
19-
# Needs the compiled .so modules and env.py from tests
20-
known_first_party = "env,pybind11_cross_module_tests,pybind11_tests,"
21-
# For black compatibility
22-
profile = "black"
23-
2418
[tool.mypy]
2519
files = ["pybind11"]
2620
python_version = "3.6"
@@ -58,4 +52,44 @@ messages_control.disable = [
5852
"invalid-name",
5953
"protected-access",
6054
"missing-module-docstring",
55+
"unused-argument", # covered by Ruff ARG
56+
]
57+
58+
[tool.ruff]
59+
select = [
60+
"E", "F", "W", # flake8
61+
"B", "B904", # flake8-bugbear
62+
"I", # isort
63+
"N", # pep8-naming
64+
"ARG", # flake8-unused-arguments
65+
"C4", # flake8-comprehensions
66+
"EM", # flake8-errmsg
67+
"ICN", # flake8-import-conventions
68+
"ISC", # flake8-implicit-str-concat
69+
"PGH", # pygrep-hooks
70+
"PIE", # flake8-pie
71+
"PL", # pylint
72+
"PT", # flake8-pytest-style
73+
"RET", # flake8-return
74+
"RUF100", # Ruff-specific
75+
"SIM", # flake8-simplify
76+
"UP", # pyupgrade
77+
"YTT", # flake8-2020
6178
]
79+
ignore = [
80+
"PLR", # Design related pylint
81+
"E501", # Line too long (Black is enough)
82+
"PT011", # Too broad with raises in pytest
83+
"PT004", # Fixture that doesn't return needs underscore (no, it is fine)
84+
"SIM118",# iter(x) is not always the same as iter(x.keys())
85+
]
86+
target-version = "py37"
87+
typing-modules = ["scikit_build_core._compat.typing"]
88+
src = ["src"]
89+
unfixable = ["T20"]
90+
exclude = []
91+
line-length = 120
92+
isort.known-first-party = ["env", "pybind11_cross_module_tests", "pybind11_tests"]
93+
94+
[tool.ruff.per-file-ignores]
95+
"tests/**" = ["EM", "N"]

setup.cfg

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,3 @@ project_urls =
4040
[options]
4141
python_requires = >=3.6
4242
zip_safe = False
43-
44-
45-
[flake8]
46-
max-line-length = 120
47-
show_source = True
48-
exclude = .git, __pycache__, build, dist, docs, tools, venv
49-
extend-ignore = E203, E722
50-
extend-select = B902, B904

0 commit comments

Comments
 (0)