diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 895f24aa..733271ac 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,7 +24,7 @@ repos: ) - repo: https://github.com/psf/black - rev: 23.10.1 + rev: 23.11.0 hooks: - id: black files: >- @@ -36,17 +36,17 @@ repos: ) - repo: https://github.com/tox-dev/pyproject-fmt - rev: 1.4.1 + rev: 1.5.1 hooks: - id: pyproject-fmt - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.4 + rev: v0.1.5 hooks: - id: ruff - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.6.1 + rev: v1.7.0 hooks: - id: mypy files: nc_py_api/ diff --git a/nc_py_api/_deffered_error.py b/nc_py_api/_deffered_error.py index 2176126c..aef532e9 100644 --- a/nc_py_api/_deffered_error.py +++ b/nc_py_api/_deffered_error.py @@ -1,5 +1,6 @@ """DeferredError class taken from PIL._util.py file.""" + class DeferredError: # pylint: disable=too-few-public-methods """Allow failing import when using it in the client mode, without `app` dependencies.""" diff --git a/nc_py_api/_session.py b/nc_py_api/_session.py index 02b4d0de..0b112390 100644 --- a/nc_py_api/_session.py +++ b/nc_py_api/_session.py @@ -414,13 +414,11 @@ def _dav_stream(self, method: str, path: str, headers: dict, data: Optional[byte def _create_adapter(self) -> Client: adapter = Client(follow_redirects=True, limits=self.limits, verify=self.cfg.options.nc_cert) - adapter.headers.update( - { - "AA-VERSION": self.cfg.aa_version, - "EX-APP-ID": self.cfg.app_name, - "EX-APP-VERSION": self.cfg.app_version, - } - ) + adapter.headers.update({ + "AA-VERSION": self.cfg.aa_version, + "EX-APP-ID": self.cfg.app_name, + "EX-APP-VERSION": self.cfg.app_version, + }) return adapter def sign_request(self, headers: dict) -> None: diff --git a/nc_py_api/ex_app/integration_fastapi.py b/nc_py_api/ex_app/integration_fastapi.py index 52acad47..56432b76 100644 --- a/nc_py_api/ex_app/integration_fastapi.py +++ b/nc_py_api/ex_app/integration_fastapi.py @@ -24,9 +24,9 @@ def nc_app(request: Request) -> NextcloudApp: """Authentication handler for requests from Nextcloud to the application.""" - user = get_username_secret_from_headers( - {"AUTHORIZATION-APP-API": request.headers.get("AUTHORIZATION-APP-API", "")} - )[0] + user = get_username_secret_from_headers({ + "AUTHORIZATION-APP-API": request.headers.get("AUTHORIZATION-APP-API", "") + })[0] request_id = request.headers.get("AA-REQUEST-ID", None) headers = {"AA-REQUEST-ID": request_id} if request_id else {} nextcloud_app = NextcloudApp(user=user, headers=headers) diff --git a/tests/_app_security_checks.py b/tests/_app_security_checks.py index 31bb1100..6f0a552d 100644 --- a/tests/_app_security_checks.py +++ b/tests/_app_security_checks.py @@ -16,13 +16,11 @@ def sign_request(req_headers: dict, secret=None, user: str = ""): headers = {} result = requests.put(request_url, headers=headers) assert result.status_code == 401 # Missing headers - headers.update( - { - "AA-VERSION": environ.get("AA_VERSION", "1.0.0"), - "EX-APP-ID": environ.get("APP_ID", "nc_py_api"), - "EX-APP-VERSION": environ.get("APP_VERSION", "1.0.0"), - } - ) + headers.update({ + "AA-VERSION": environ.get("AA_VERSION", "1.0.0"), + "EX-APP-ID": environ.get("APP_ID", "nc_py_api"), + "EX-APP-VERSION": environ.get("APP_VERSION", "1.0.0"), + }) sign_request(headers) result = requests.put(request_url, headers=headers) assert result.status_code == 200