Skip to content

Commit

Permalink
fix: fixups
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
  • Loading branch information
henryiii committed Feb 17, 2023
1 parent 462c2c9 commit d36b7d2
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 18 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ repos:
- id: fix-smartquotes

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.238
rev: v0.0.247
hooks:
- id: ruff
args: ["--fix"]
args: ["--fix", "--show-fixes"]

# Checking for common mistakes
- repo: https://github.com/pre-commit/pygrep-hooks
Expand Down
2 changes: 1 addition & 1 deletion pybind11/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys

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

Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,11 @@ select = [
"YTT", # flake8-2020
]
ignore = [
"PLR2004", "PLR0913",
"PLR", # Design related pylint
"E501", # Line too long (Black is enough)
"PT011", # Too broad with raises in pytest
"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"
typing-modules = ["scikit_build_core._compat.typing"]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_const_name.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

@pytest.mark.parametrize("func", [m.const_name_tests, m.underscore_tests])
@pytest.mark.parametrize(
"selector, expected",
("selector", "expected"),
enumerate(
(
"",
Expand Down
5 changes: 1 addition & 4 deletions tests/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,7 @@ def test_flaky_exception_failure_point_str():
)
assert not py_err_set_after_what
lines = what.splitlines()
if env.PYPY and len(lines) == 3:
n = 3 # Traceback is missing.
else:
n = 5
n = 3 if env.PYPY and len(lines) == 3 else 5
assert (
lines[:n]
== [
Expand Down
10 changes: 4 additions & 6 deletions tests/test_modules.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import builtins

import pytest

import env
Expand Down Expand Up @@ -86,12 +88,8 @@ def test_builtin_key_type():
Previous versions of pybind11 would add a unicode key in python 2.
"""
if hasattr(__builtins__, "keys"):
keys = __builtins__.keys()
else: # this is to make pypy happy since builtins is different there.
keys = __builtins__.__dict__.keys()

assert {type(k) for k in keys} == {str}
assert all(type(k) == str for k in dir(builtins))
assert all(type(k) == str for k in __builtins__.__dict__)


@pytest.mark.xfail("env.PYPY", reason="PyModule_GetName()")
Expand Down
6 changes: 3 additions & 3 deletions tests/test_sequences_and_iterators.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ def test_iterator_referencing():
vec = m.VectorNonCopyableIntPair()
vec.append([3, 4])
vec.append([5, 7])
assert [int(x) for x in vec] == [3, 5]
assert [int(x) for x in vec.keys()] == [3, 5]
assert [int(x) for x in vec.values()] == [4, 7]
for x in vec:
for x in vec.keys():
x.set(int(x) + 1)
for x in vec.values():
x.set(int(x) + 10)
assert [int(x) for x in vec] == [4, 6]
assert [int(x) for x in vec.keys()] == [4, 6]
assert [int(x) for x in vec.values()] == [14, 17]


Expand Down

0 comments on commit d36b7d2

Please sign in to comment.