From df23e41f496a21a4242124895471af7fd84b0698 Mon Sep 17 00:00:00 2001 From: Mathias Laurin Date: Sat, 10 Feb 2024 11:22:11 +0100 Subject: [PATCH 1/3] flake8: Ignore E704 multiple statements on one line black is our SSOT regarding formatting issues. --- .flake8 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.flake8 b/.flake8 index 314ad52d..379fd536 100644 --- a/.flake8 +++ b/.flake8 @@ -1,5 +1,5 @@ [flake8] force-check = True filename = *.pyx,*.pxd,*.py -ignore = E211, E225, E226, E227, E402, E501, E999, PT011, PT012, W503 +ignore = E704, E211, E225, E226, E227, E402, E501, E999, PT011, PT012, W503 extend-ignore = E203 From b8b13b7bdf67beeb732b7f338178d820fb164fb4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 5 Feb 2024 19:16:50 +0000 Subject: [PATCH 2/3] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/charliermarsh/ruff-pre-commit: v0.1.9 → v0.2.0](https://github.com/charliermarsh/ruff-pre-commit/compare/v0.1.9...v0.2.0) - [github.com/psf/black: 23.12.1 → 24.1.1](https://github.com/psf/black/compare/23.12.1...24.1.1) - [github.com/pycqa/flake8: 6.1.0 → 7.0.0](https://github.com/pycqa/flake8/compare/6.1.0...7.0.0) - [github.com/abravalheri/validate-pyproject: v0.15 → v0.16](https://github.com/abravalheri/validate-pyproject/compare/v0.15...v0.16) --- .pre-commit-config.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 06703513..56fe01cf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -32,11 +32,11 @@ repos: - id: end-of-file-fixer - id: trailing-whitespace - repo: 'https://github.com/charliermarsh/ruff-pre-commit' - rev: v0.1.9 + rev: v0.2.0 hooks: - id: ruff - repo: 'https://github.com/psf/black' - rev: 23.12.1 + rev: 24.1.1 hooks: - id: black types: [python] @@ -45,7 +45,7 @@ repos: hooks: - id: cython-lint - repo: 'https://github.com/pycqa/flake8' - rev: 6.1.0 + rev: 7.0.0 hooks: - id: flake8 additional_dependencies: @@ -77,6 +77,6 @@ repos: - '--py38-plus' - '--keep-runtime-typing' - repo: 'https://github.com/abravalheri/validate-pyproject' - rev: v0.15 + rev: v0.16 hooks: - id: validate-pyproject From b9fb2240fed4883b3d72971f39d4852d8d348997 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 5 Feb 2024 19:17:23 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- setup.py | 14 ++++++++------ src/mbedtls/cipher/AES.py | 6 ++---- src/mbedtls/cipher/CHACHA20.py | 6 ++---- src/mbedtls/cipher/__init__.py | 24 ++++++++---------------- src/mbedtls/hashlib.py | 3 +-- src/mbedtls/hmac.py | 3 +-- src/mbedtls/tls.py | 9 +++------ 7 files changed, 25 insertions(+), 40 deletions(-) diff --git a/setup.py b/setup.py index d6b77c20..caba88f1 100644 --- a/setup.py +++ b/setup.py @@ -135,12 +135,14 @@ def from_env(var): sources=[os.path.join(dirpath, fn)], library_dirs=library_dirs, libraries=libraries, - define_macros=[ - ("CYTHON_TRACE", "1"), - ("CYTHON_TRACE_NOGIL", "1"), - ] - if coverage - else [], + define_macros=( + [ + ("CYTHON_TRACE", "1"), + ("CYTHON_TRACE_NOGIL", "1"), + ] + if coverage + else [] + ), ) extension.cython_directives = {"language_level": "3str"} if coverage: diff --git a/src/mbedtls/cipher/AES.py b/src/mbedtls/cipher/AES.py index 195dcc2e..2564f31c 100644 --- a/src/mbedtls/cipher/AES.py +++ b/src/mbedtls/cipher/AES.py @@ -28,8 +28,7 @@ def new( mode: Literal[Mode.CCM, Mode.GCM], iv: Optional[bytes] = ..., ad: Optional[bytes] = ..., -) -> AEADCipher: - ... +) -> AEADCipher: ... @overload @@ -37,8 +36,7 @@ def new( key: bytes, mode: Literal[Mode.CBC, Mode.CFB, Mode.CTR, Mode.ECB, Mode.OFB, Mode.XTS], iv: Optional[bytes] = ..., -) -> Cipher: - ... +) -> Cipher: ... def new( diff --git a/src/mbedtls/cipher/CHACHA20.py b/src/mbedtls/cipher/CHACHA20.py index 97def1f8..38796677 100644 --- a/src/mbedtls/cipher/CHACHA20.py +++ b/src/mbedtls/cipher/CHACHA20.py @@ -26,8 +26,7 @@ def new( key: bytes, mode: Literal[Mode.STREAM], iv: Optional[bytes] = ..., -) -> Cipher: - ... +) -> Cipher: ... @overload @@ -36,8 +35,7 @@ def new( mode: Literal[Mode.CHACHAPOLY], iv: Optional[bytes] = ..., ad: Optional[bytes] = ..., -) -> AEADCipher: - ... +) -> AEADCipher: ... def new( diff --git a/src/mbedtls/cipher/__init__.py b/src/mbedtls/cipher/__init__.py index 9a346cd2..fc255bd5 100644 --- a/src/mbedtls/cipher/__init__.py +++ b/src/mbedtls/cipher/__init__.py @@ -47,39 +47,31 @@ @runtime_checkable class CipherType(Protocol): @property - def __name__(self) -> str: - ... + def __name__(self) -> str: ... @property - def block_size(self) -> int: - ... + def block_size(self) -> int: ... @property - def key_size(self) -> int: - ... + def key_size(self) -> int: ... - def new(self, key: bytes, mode: Mode, iv: Optional[bytes]) -> Cipher: - ... + def new(self, key: bytes, mode: Mode, iv: Optional[bytes]) -> Cipher: ... @runtime_checkable class AEADCipherType(Protocol): @property - def __name__(self) -> str: - ... + def __name__(self) -> str: ... @property - def block_size(self) -> int: - ... + def block_size(self) -> int: ... @property - def key_size(self) -> int: - ... + def key_size(self) -> int: ... def new( self, key: bytes, mode: Mode, iv: Optional[bytes], ad: Optional[bytes] - ) -> AEADCipher: - ... + ) -> AEADCipher: ... __all__ = ( diff --git a/src/mbedtls/hashlib.py b/src/mbedtls/hashlib.py index cda86dc7..377d1d79 100644 --- a/src/mbedtls/hashlib.py +++ b/src/mbedtls/hashlib.py @@ -22,8 +22,7 @@ class Algorithm(Protocol): - def __call__(self, buffer: Optional[bytes] = ...) -> Hash: - ... + def __call__(self, buffer: Optional[bytes] = ...) -> Hash: ... def new(name: str, buffer: Optional[bytes] = None) -> Hash: diff --git a/src/mbedtls/hmac.py b/src/mbedtls/hmac.py index 7b5de6ae..78db5da5 100644 --- a/src/mbedtls/hmac.py +++ b/src/mbedtls/hmac.py @@ -22,8 +22,7 @@ class Algorithm(Protocol): - def __call__(self, key: bytes, buffer: Optional[bytes] = ...) -> Hmac: - ... + def __call__(self, key: bytes, buffer: Optional[bytes] = ...) -> Hmac: ... def new( diff --git a/src/mbedtls/tls.py b/src/mbedtls/tls.py index 8cbebff2..62cf56e8 100644 --- a/src/mbedtls/tls.py +++ b/src/mbedtls/tls.py @@ -413,16 +413,13 @@ def shutdown(self, how: int) -> None: # PEP 543 adds the following methods. @overload - def do_handshake(self) -> None: - ... + def do_handshake(self) -> None: ... @overload - def do_handshake(self, address: _Address) -> None: - ... + def do_handshake(self, address: _Address) -> None: ... @overload - def do_handshake(self, flags: int, address: _Address) -> None: - ... + def do_handshake(self, flags: int, address: _Address) -> None: ... def do_handshake(self, *args): # type: ignore[no-untyped-def] # pylint: disable=too-many-branches