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

chore: update hooks and Ruff config #4904

Merged
merged 1 commit into from
Oct 27, 2023
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
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,27 @@ repos:

# Clang format the codebase automatically
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: "v16.0.6"
rev: "v17.0.3"
hooks:
- id: clang-format
types_or: [c++, c, cuda]

# Black, the code formatter, natively supports pre-commit
- repo: https://github.com/psf/black-pre-commit-mirror
rev: "23.9.1" # Keep in sync with blacken-docs
rev: "23.10.1" # Keep in sync with blacken-docs
hooks:
- id: black

# Ruff, the Python auto-correcting linter written in Rust
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.292
rev: v0.1.2
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]

# Check static types with mypy
- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.5.1"
rev: "v1.6.1"
hooks:
- id: mypy
args: []
Expand All @@ -67,7 +67,7 @@ repos:

# Standard hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v4.4.0"
rev: "v4.5.0"
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand Down Expand Up @@ -98,7 +98,7 @@ repos:

# Avoid directional quotes
- repo: https://github.com/sirosen/texthooks
rev: "0.5.0"
rev: "0.6.2"
hooks:
- id: fix-ligatures
- id: fix-smartquotes
Expand Down Expand Up @@ -147,7 +147,7 @@ repos:

# PyLint has native support - not always usable, but works for us
- repo: https://github.com/PyCQA/pylint
rev: "v3.0.0"
rev: "v3.0.1"
hooks:
- id: pylint
files: ^pybind11
16 changes: 8 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ignore = [

[tool.mypy]
files = ["pybind11"]
python_version = "3.6"
python_version = "3.7"
strict = true
show_error_codes = true
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
Expand Down Expand Up @@ -57,10 +57,13 @@ messages_control.disable = [
"unused-argument", # covered by Ruff ARG
]


[tool.ruff]
select = [
"E", "F", "W", # flake8
target-version = "py37"
src = ["src"]
line-length = 120

[tool.ruff.lint]
extend-select = [
"B", # flake8-bugbear
"I", # isort
"N", # pep8-naming
Expand All @@ -86,13 +89,10 @@ ignore = [
"PT004", # Fixture that doesn't return needs underscore (no, it is fine)
"SIM118", # iter(x) is not always the same as iter(x.keys())
]
target-version = "py37"
src = ["src"]
unfixable = ["T20"]
exclude = []
line-length = 120
isort.known-first-party = ["env", "pybind11_cross_module_tests", "pybind11_tests"]

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"tests/**" = ["EM", "N", "E721"]
"tests/test_call_policies.py" = ["PLC1901"]
2 changes: 1 addition & 1 deletion tests/test_numpy_dtypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ py::array mkarray_via_buffer(size_t n) {
do { \
(s).bool_ = (i) % 2 != 0; \
(s).uint_ = (uint32_t) (i); \
(s).float_ = (float) (i) *1.5f; \
(s).float_ = (float) (i) * 1.5f; \
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice clang-format update. :)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, a free space!

(s).ldbl_ = (long double) (i) * -2.5L; \
} while (0)

Expand Down
4 changes: 2 additions & 2 deletions tests/test_pytypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -662,8 +662,8 @@ TEST_SUBMODULE(pytypes, m) {
// This is "most correct" and enforced on these platforms.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But why is it now also indenting this?
Just wondering. Maybe we get more free spaces here in the next upgrade?

# define PYBIND11_AUTO_IT auto it
#else
// This works on many platforms and is (unfortunately) reflective of existing user code.
// NOLINTNEXTLINE(bugprone-macro-parentheses)
// This works on many platforms and is (unfortunately) reflective of existing user code.
// NOLINTNEXTLINE(bugprone-macro-parentheses)
# define PYBIND11_AUTO_IT auto &it
#endif

Expand Down