Skip to content

Commit

Permalink
Update all minor versions (master) (minor) (#2548)
Browse files Browse the repository at this point in the history
* Update all minor versions

* Add Ruff

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Stéphane Brunner <[email protected]>
  • Loading branch information
renovate[bot] and sbrunner authored Dec 3, 2024
1 parent afbe6c2 commit 4c777b7
Show file tree
Hide file tree
Showing 48 changed files with 321 additions and 224 deletions.
3 changes: 0 additions & 3 deletions .bandit.yaml

This file was deleted.

31 changes: 8 additions & 23 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,39 +61,24 @@ repos:
rev: v0.1.8
hooks:
- id: ripsecrets
- repo: https://github.com/PyCQA/autoflake
rev: v2.3.1
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.1
hooks:
- id: autoflake
- repo: https://github.com/asottile/pyupgrade
rev: v3.19.0
hooks:
- id: pyupgrade
args:
- --py39-plus
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
# isort issue: https://github.com/PyCQA/isort/issues/1889
- id: ruff-format
args:
- --project=c2cwsgiutils
- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: black
exclude: .*\.html
- --line-length=110
- repo: https://github.com/PyCQA/prospector
rev: v1.13.3
hooks:
- id: prospector
args:
- --tool=pydocstyle
- --tool=ruff
- --die-on-tool-error
- --output-format=pylint
additional_dependencies:
- prospector-profile-duplicated==1.8.0 # pypi
- prospector-profile-utils==1.12.2 # pypi
- prospector-profile-duplicated==1.8.1 # pypi
- prospector-profile-utils==1.14.0 # pypi
- ruff==0.8.1 # pypi
- repo: https://github.com/sbrunner/jsonschema-validator
rev: 0.3.2
hooks:
Expand Down
25 changes: 4 additions & 21 deletions .prospector.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
inherits:
- utils:base
- utils:no-design-checks
- utils:c2cwsgiutils
- utils:fix
- utils:unsafe
- duplicated

doc-warnings: true

ignore-paths:
- docs
- acceptance_tests
Expand All @@ -16,24 +16,7 @@ pylint:
extension-pkg-allow-list:
- ujson
- lxml
disable:
- no-else-return
- no-else-raise
- missing-module-docstring
- missing-timeout # A default timeout is set

pydocstyle:
disable:
- D104 # Missing docstring in public package
- D105 # Missing docstring in magic method
- D107 # Missing docstring in __init__

pycodestyle:
disable:
# Buggy checks with Python 3.12
- E221 # multiple spaces before operator
- E702 # multiple statements on one line (semicolon)

bandit:
mypy:
options:
config: .bandit.yaml
python_version: '3.10'
49 changes: 40 additions & 9 deletions acceptance_tests/app/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions acceptance_tests/app/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ coverage = "7.6.8"

[tool.poetry.dev-dependencies]
# pylint = { version = "2.15.6" }
prospector = { extras = ["with_bandit", "with_mypy"], version = "1.13.3" }
prospector-profile-duplicated = "1.6.0"
prospector-profile-utils = "1.9.1"
prospector = { version = "1.13.3", extras = ["with_bandit", "with_mypy", "with_ruff"] }
prospector-profile-duplicated = "1.8.1"
prospector-profile-utils = "1.14.0"

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand Down
1 change: 1 addition & 0 deletions c2cwsgiutils/acceptance/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def retry(
tries: number of times to try (not retry) before giving up
delay: initial delay between retries in seconds
backoff: backoff multiplier e.g. value of 2 will double the delay each retry
"""

def deco_retry(f: typing.Callable[..., typing.Any]) -> typing.Callable[..., typing.Any]:
Expand Down
5 changes: 3 additions & 2 deletions c2cwsgiutils/acceptance/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class Connection:
"""The connection."""

def __init__(self, base_url: str, origin: str) -> None:
"""Initialize the connection."""
self.base_url = base_url
if not self.base_url.endswith("/"):
self.base_url += "/"
Expand Down Expand Up @@ -93,10 +94,10 @@ def get_xml(
check_response(r, expected_status, cache_expected=cache_expected)
self._check_cors(cors, r)
r.raw.decode_content = True
doc = etree.parse(r.raw) # nosec
doc = etree.parse(r.raw) # noqa: S320
if schema is not None:
with open(schema, encoding="utf-8") as schema_file:
xml_schema = etree.XMLSchema(etree.parse(schema_file)) # nosec
xml_schema = etree.XMLSchema(etree.parse(schema_file)) # noqa: S320
xml_schema.assertValid(doc)
return doc

Expand Down
8 changes: 5 additions & 3 deletions c2cwsgiutils/acceptance/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import skimage.transform # pylint: disable=import-error

if TYPE_CHECKING:
from typing import TypeAlias
from typing_extensions import TypeAlias

NpNdarrayInt: TypeAlias = np.ndarray[np.uint8, Any]
else:
Expand Down Expand Up @@ -89,6 +89,7 @@ def check_image(
level: The minimum similarity level (between 0.0 and 1.0), default to 1.0
generate_expected_image: If `True` generate the expected image instead of checking it
use_mask: If `False` don't use the mask event if the file exists
"""
assert image_to_check is not None, "Image required"
image_file_basename = os.path.splitext(os.path.basename(expected_filename))[0]
Expand Down Expand Up @@ -122,7 +123,7 @@ def check_image(
if np.issubdtype(mask.dtype, np.floating):
mask = (mask * 255).astype("uint8")

assert ((0 < mask) & (mask < 255)).sum() == 0, "Mask should be only black and white image"
assert ((mask > 0) & (mask < 255)).sum() == 0, "Mask should be only black and white image"

# Convert to boolean
mask = mask == 0
Expand All @@ -139,7 +140,7 @@ def check_image(
return
if not os.path.isfile(expected_filename):
skimage.io.imsave(expected_filename, image_to_check)
assert False, "Expected image not found: " + expected_filename
raise AssertionError("Expected image not found: " + expected_filename)
expected = skimage.io.imread(expected_filename)
assert expected is not None, "Wrong image: " + expected_filename
expected = normalize_image(expected)
Expand Down Expand Up @@ -201,6 +202,7 @@ def check_screenshot(
level: See `check_image`
generate_expected_image: See `check_image`
use_mask: See `check_image`
"""
if headers is None:
headers = {}
Expand Down
26 changes: 13 additions & 13 deletions c2cwsgiutils/acceptance/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion c2cwsgiutils/acceptance/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"dependencies": {
"commander": "12.1.0",
"puppeteer": "23.7.1"
"puppeteer": "23.9.0"
},
"type": "module"
}
1 change: 1 addition & 0 deletions c2cwsgiutils/acceptance/print.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def __init__(self, base_url: str, origin: str) -> None:
base_url: The base URL to the print server (including the /print)
app: The name of the application to use
origin: The origin and referrer to include in the requests
"""
super().__init__(base_url=base_url, origin=origin)
self.session.headers["Referrer"] = origin
Expand Down
3 changes: 2 additions & 1 deletion c2cwsgiutils/acceptance/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def retry_timeout(what: Callable[[], Any], timeout: float = _DEFAULT_TIMEOUT, in
what: the function to try
timeout: the timeout to get a success
interval: the interval between try
"""
timeout = time.perf_counter() + timeout
while True:
Expand All @@ -46,7 +47,7 @@ def retry_timeout(what: Callable[[], Any], timeout: float = _DEFAULT_TIMEOUT, in
error = str(e)
_LOG.info(" Failed: %s", e)
if time.perf_counter() > timeout:
assert False, "Timeout: " + error
raise AssertionError("Timeout: " + error)
time.sleep(interval)


Expand Down
Loading

0 comments on commit 4c777b7

Please sign in to comment.