Skip to content

Update ruff #178

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

Merged
merged 3 commits into from
Mar 17, 2025
Merged
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
8 changes: 6 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -17,11 +17,15 @@ jobs:
cancel_others: 'true'
concurrent_skipping: same_content
ruff:
runs-on: ubuntu-latest
needs: pre_job
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: chartboost/ruff-action@v1
- uses: astral-sh/ruff-action@v3
with:
version: latest
- run: ruff check
- run: ruff format --check
test:
needs: ruff
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: check-merge-conflict
- id: debug-statements
@@ -9,7 +9,7 @@ repos:
- id: check-yaml
- id: check-json
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.0
rev: v0.9.9
hooks:
- id: ruff
- id: ruff-format
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ responses = "^0.13.0"
sphinx = "^3.5.2"
sphinx-autobuild = "^2021.3.14"
coverage = "^7"
ruff = ">=0.8.0"
ruff = ">=0.9.9"
pytest-ruff = "^0.3.2"

[build-system]
4 changes: 2 additions & 2 deletions src/cryptojwt/jws/dsa.py
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@
"""

if not isinstance(key, ec.EllipticCurvePrivateKey):
raise TypeError("The private key must be an instance of " "ec.EllipticCurvePrivateKey")
raise TypeError("The private key must be an instance of ec.EllipticCurvePrivateKey")

Check warning on line 43 in src/cryptojwt/jws/dsa.py

Codecov / codecov/patch

src/cryptojwt/jws/dsa.py#L43

Added line #L43 was not covered by tests

self._cross_check(key.public_key())
num_bits = key.curve.key_size
@@ -62,7 +62,7 @@
:return: True
"""
if not isinstance(key, ec.EllipticCurvePublicKey):
raise TypeError("The public key must be an instance of " "ec.EllipticCurvePublicKey")
raise TypeError("The public key must be an instance of ec.EllipticCurvePublicKey")

Check warning on line 65 in src/cryptojwt/jws/dsa.py

Codecov / codecov/patch

src/cryptojwt/jws/dsa.py#L65

Added line #L65 was not covered by tests
self._cross_check(key)

num_bits = key.curve.key_size
3 changes: 1 addition & 2 deletions tests/test_02_jwk.py
Original file line number Diff line number Diff line change
@@ -150,8 +150,7 @@ def test_serialize_rsa_priv_key():
ECKEY = {
"crv": "P-521",
"x": "AekpBQ8ST8a8VcfVOTNl353vSrDCLLJXmPk06wTjxrrjcBpXp5EOnYG_NjFZ6OvLFV1jSfS9tsz4qUxcWceqwQGk",
"y": "ADSmRA43Z1DSNx_RvcLI87cdL07l6jQyyBXMoxVg_l2Th"
"-x3S1WDhjDly79ajL4Kkd0AZMaZmh9ubmf63e3kyMj2",
"y": "ADSmRA43Z1DSNx_RvcLI87cdL07l6jQyyBXMoxVg_l2Th-x3S1WDhjDly79ajL4Kkd0AZMaZmh9ubmf63e3kyMj2",
"d": "AY5pb7A0UFiB3RELSD64fTLOSV_jazdF7fLYyuTw8lOfRhWg6Y6rUrPAxerEzgdRhajnu0ferB0d53vM9mE15j2C",
}

2 changes: 1 addition & 1 deletion tests/test_03_key_bundle.py
Original file line number Diff line number Diff line change
@@ -74,7 +74,7 @@ def full_path(local_file):
"kid": "rsa1",
},
{
"k": "YTEyZjBlMDgxMGI4YWU4Y2JjZDFiYTFlZTBjYzljNDU3YWM0ZWNiNzhmNmFlYTNkNT" "Y0NzMzYjE",
"k": "YTEyZjBlMDgxMGI4YWU4Y2JjZDFiYTFlZTBjYzljNDU3YWM0ZWNiNzhmNmFlYTNkNTY0NzMzYjE",
"kty": "oct",
},
]
4 changes: 2 additions & 2 deletions tests/test_06_jws.py
Original file line number Diff line number Diff line change
@@ -418,7 +418,7 @@ def test_a_1_1a():


def test_a_1_1b():
payload = b'{"iss":"joe",\r\n "exp":1300819380,' b'\r\n "http://example.com/is_root":true}'
payload = b'{"iss":"joe",\r\n "exp":1300819380,\r\n "http://example.com/is_root":true}'
val = b64e(payload)
assert val == (
b"eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9"
@@ -430,7 +430,7 @@ def test_a_1_1c():
hmac = intarr2bin(HMAC_KEY)
signer = SIGNER_ALGS["HS256"]
header = b'{"typ":"JWT",\r\n "alg":"HS256"}'
payload = b'{"iss":"joe",\r\n "exp":1300819380,' b'\r\n "http://example.com/is_root":true}'
payload = b'{"iss":"joe",\r\n "exp":1300819380,\r\n "http://example.com/is_root":true}'
sign_input = b64e(header) + b"." + b64e(payload)
sig = signer.sign(sign_input, hmac)
assert b64e(sig) == b"dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk"