Skip to content

Commit 9e45865

Browse files
committed
Merge remote-tracking branch 'origin/pre-commit-ci-update-config' into pre-commit-ci-update-config
# Conflicts: # .pre-commit-config.yaml
2 parents e23a001 + 103ce63 commit 9e45865

File tree

11 files changed

+42
-79
lines changed

11 files changed

+42
-79
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ repos:
4141
- id: pyproject-fmt
4242

4343
- repo: https://github.com/astral-sh/ruff-pre-commit
44-
rev: v0.7.4
44+
rev: v0.9.3
4545
hooks:
4646
- id: ruff
4747

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## [0.18.2 - 2025-01-19]
6+
7+
### Changed
8+
9+
- Default "User-Agent" for ExApps now set to `ExApp/appid/version (httpx/version)`. #329
10+
- `System Trust Store` from now are used by default. #328
11+
12+
## [0.18.1 - 2025-01-14]
13+
14+
### Fixed
15+
16+
- Chunked Upload V2 not working on Nextcloud 30 and later. #324 Thanks to @DrZoidberg09
17+
518
## [0.18.0 - 2024-10-09]
619

720
### Added

nc_py_api/_session.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from os import environ
1313

1414
from httpx import AsyncClient, Client, Headers, Limits, ReadTimeout, Request, Response
15+
from httpx import __version__ as httpx_version
1516
from starlette.requests import HTTPConnection
1617

1718
from . import options
@@ -511,6 +512,7 @@ def _create_adapter(self, dav: bool = False) -> AsyncClient | Client:
511512
"AA-VERSION": self.cfg.aa_version,
512513
"EX-APP-ID": self.cfg.app_name,
513514
"EX-APP-VERSION": self.cfg.app_version,
515+
"user-agent": f"ExApp/{self.cfg.app_name}/{self.cfg.app_version} (httpx/{httpx_version})",
514516
},
515517
)
516518

@@ -535,6 +537,7 @@ def _create_adapter(self, dav: bool = False) -> AsyncClient | Client:
535537
"AA-VERSION": self.cfg.aa_version,
536538
"EX-APP-ID": self.cfg.app_name,
537539
"EX-APP-VERSION": self.cfg.app_version,
540+
"User-Agent": f"ExApp/{self.cfg.app_name}/{self.cfg.app_version} (httpx/{httpx_version})",
538541
},
539542
)
540543

nc_py_api/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""Version of nc_py_api."""
22

3-
__version__ = "0.18.0"
3+
__version__ = "0.18.2"

nc_py_api/files/files.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,8 @@ def __upload_stream(self, path: str, fp, chunk_size: int) -> FsNode:
485485
response = self._session.adapter_dav.request("MKCOL", _dav_path)
486486
check_error(response)
487487
try:
488-
start_bytes = end_bytes = chunk_number = 0
488+
start_bytes = end_bytes = 0
489+
chunk_number = 1
489490
while True:
490491
piece = fp.read(chunk_size)
491492
if not piece:

nc_py_api/options.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,22 @@
3333
SSL certificates (a.k.a CA bundle) used to verify the identity of requested hosts. Either **True** (default CA bundle),
3434
a path to an SSL certificate file, or **False** (which will disable verification)."""
3535
str_val = environ.get("NPA_NC_CERT", "True")
36-
NPA_NC_CERT = True
36+
# https://github.com/encode/httpx/issues/302
37+
# when "httpx" will switch to use "truststore" by default - uncomment next line
38+
# NPA_NC_CERT = True
3739
if str_val.lower() in ("false", "0"):
3840
NPA_NC_CERT = False
3941
elif str_val.lower() not in ("true", "1"):
4042
NPA_NC_CERT = str_val
43+
else:
44+
# Temporary workaround, see comment above.
45+
# Use system certificate stores
46+
47+
import ssl
48+
49+
import truststore
50+
51+
NPA_NC_CERT = truststore.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
4152

4253
CHUNKED_UPLOAD_V2 = environ.get("CHUNKED_UPLOAD_V2", True)
4354
"""Option to enable/disable **version 2** chunked upload(better Object Storages support).

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ dependencies = [
4949
"httpx>=0.25.2",
5050
"pydantic>=2.1.1",
5151
"python-dotenv>=1",
52+
"truststore==0.10",
5253
"xmltodict>=0.13",
5354
]
5455
optional-dependencies.app = [

tests/actual_tests/files_test.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,6 +1159,7 @@ async def test_create_update_delete_tag_async(anc_any):
11591159

11601160

11611161
def test_get_assign_unassign_tag(nc_any):
1162+
11621163
with contextlib.suppress(NextcloudExceptionNotFound):
11631164
nc_any.files.delete_tag(nc_any.files.tag_by_name("test_nc_py_api"))
11641165
with contextlib.suppress(NextcloudExceptionNotFound):
@@ -1174,6 +1175,10 @@ def test_get_assign_unassign_tag(nc_any):
11741175
new_file = nc_any.files.upload("/test_dir_tmp/tag_test.txt", content=b"")
11751176
new_file = nc_any.files.by_id(new_file)
11761177
assert nc_any.files.get_tags(new_file) == []
1178+
1179+
if nc_any.srv_version["major"] > 30:
1180+
pytest.skip("Skip temporary on master branch")
1181+
11771182
assert len(nc_any.files.list_by_criteria(tags=[tag1])) == 0
11781183
nc_any.files.assign_tag(new_file, tag1)
11791184
assert isinstance(nc_any.files.get_tags(new_file)[0], SystemTag)
@@ -1206,6 +1211,10 @@ async def test_get_assign_unassign_tag_async(anc_any):
12061211
new_file = await anc_any.files.upload("/test_dir_tmp/tag_test.txt", content=b"")
12071212
new_file = await anc_any.files.by_id(new_file)
12081213
assert await anc_any.files.get_tags(new_file) == []
1214+
1215+
if (await anc_any.srv_version)["major"] > 30:
1216+
pytest.skip("Skip temporary on master branch")
1217+
12091218
assert len(await anc_any.files.list_by_criteria(tags=[tag1])) == 0
12101219
await anc_any.files.assign_tag(new_file, tag1)
12111220
assert isinstance((await anc_any.files.get_tags(new_file))[0], SystemTag)

tests/actual_tests/z_special_test.py

Lines changed: 0 additions & 49 deletions
This file was deleted.

tests/data/nc_pass_confirm.patch

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)