Skip to content

Commit 52b48f1

Browse files
authored
drop python 3.9 support (#180)
Before adding support for **Async**, we remove Python 3.9 support in order to reduce the amount of work later, since support for asynchrony will add a lot of duplicate code. --------- Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
1 parent 9eed252 commit 52b48f1

35 files changed

+177
-233
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@
22

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

5-
## [0.6.1 - 202x-xx-xx]
5+
## [0.7.0 - 2022-12-2x]
66

77
### Added
88

99
- set_handlers: `enabled_handler`, `heartbeat_handler` now can be async(Coroutines). #175
1010

11+
### Changed
12+
13+
- drop Python 3.9 support. #180
14+
- internal code refactoring and clean-up #177
15+
1116
## [0.6.0 - 2023-12-06]
1217

1318
### Added

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
[![codecov](https://codecov.io/github/cloud-py-api/nc_py_api/branch/main/graph/badge.svg?token=C91PL3FYDQ)](https://codecov.io/github/cloud-py-api/nc_py_api)
1010

1111
![NextcloudVersion](https://img.shields.io/badge/Nextcloud-26%20%7C%2027%20%7C%2028-blue)
12-
![PythonVersion](https://img.shields.io/badge/python-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12-blue)
12+
![PythonVersion](https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12-blue)
1313
![impl](https://img.shields.io/pypi/implementation/nc_py_api)
1414
![pypi](https://img.shields.io/pypi/v/nc_py_api.svg)
1515

benchmarks/aa_overhead_dav_download.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from getpass import getuser
22
from random import randbytes
33
from time import perf_counter
4-
from typing import Any, Union
4+
from typing import Any
55

66
import matplotlib.pyplot as plt
77
from aa_overhead_common import measure_overhead, os_id
@@ -12,7 +12,7 @@
1212
CACHE_SESS = False
1313

1414

15-
def measure_download_1mb(nc_obj: Union[Nextcloud, NextcloudApp]) -> [Any, float]:
15+
def measure_download_1mb(nc_obj: Nextcloud | NextcloudApp) -> [Any, float]:
1616
__result = None
1717
small_file_name = "1Mb.bin"
1818
small_file = randbytes(1024 * 1024)

benchmarks/aa_overhead_dav_download_stream.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from io import BytesIO
33
from random import randbytes
44
from time import perf_counter
5-
from typing import Any, Union
5+
from typing import Any
66

77
import matplotlib.pyplot as plt
88
from aa_overhead_common import measure_overhead, os_id
@@ -13,7 +13,7 @@
1313
CACHE_SESS = False
1414

1515

16-
def measure_download_100mb(nc_obj: Union[Nextcloud, NextcloudApp]) -> [Any, float]:
16+
def measure_download_100mb(nc_obj: Nextcloud | NextcloudApp) -> [Any, float]:
1717
__result = None
1818
medium_file_name = "100Mb.bin"
1919
medium_file = BytesIO()

benchmarks/aa_overhead_dav_upload.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from getpass import getuser
22
from random import randbytes
33
from time import perf_counter
4-
from typing import Any, Union
4+
from typing import Any
55

66
import matplotlib.pyplot as plt
77
from aa_overhead_common import measure_overhead, os_id
@@ -12,7 +12,7 @@
1212
CACHE_SESS = False
1313

1414

15-
def measure_upload_1mb(nc_obj: Union[Nextcloud, NextcloudApp]) -> [Any, float]:
15+
def measure_upload_1mb(nc_obj: Nextcloud | NextcloudApp) -> [Any, float]:
1616
__result = None
1717
small_file_name = "1Mb.bin"
1818
small_file = randbytes(1024 * 1024)

benchmarks/aa_overhead_dav_upload_stream.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from io import BytesIO
33
from random import randbytes
44
from time import perf_counter
5-
from typing import Any, Union
5+
from typing import Any
66

77
import matplotlib.pyplot as plt
88
from aa_overhead_common import measure_overhead, os_id
@@ -13,7 +13,7 @@
1313
CACHE_SESS = False
1414

1515

16-
def measure_upload_100mb(nc_obj: Union[Nextcloud, NextcloudApp]) -> [Any, float]:
16+
def measure_upload_100mb(nc_obj: Nextcloud | NextcloudApp) -> [Any, float]:
1717
__result = None
1818
medium_file_name = "100Mb.bin"
1919
medium_file = BytesIO()

benchmarks/aa_overhead_ocs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from getpass import getuser
22
from time import perf_counter
3-
from typing import Any, Union
3+
from typing import Any
44

55
import matplotlib.pyplot as plt
66
from aa_overhead_common import measure_overhead, os_id
@@ -11,7 +11,7 @@
1111
CACHE_SESS = False
1212

1313

14-
def measure_get_details(nc_obj: Union[Nextcloud, NextcloudApp]) -> [Any, float]:
14+
def measure_get_details(nc_obj: Nextcloud | NextcloudApp) -> [Any, float]:
1515
__result = None
1616
start_time = perf_counter()
1717
for _ in range(ITERS):

benchmarks/conf.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from typing import Optional
2-
31
from nc_py_api import Nextcloud, NextcloudApp
42

53
NC_CFGS = {
@@ -39,19 +37,19 @@
3937
}
4038

4139

42-
def init_nc(url, cfg) -> Optional[Nextcloud]:
40+
def init_nc(url, cfg) -> Nextcloud | None:
4341
if cfg.get("nc_auth_user", "") and cfg.get("nc_auth_pass", ""):
4442
return Nextcloud(nc_auth_user=cfg["nc_auth_user"], nc_auth_pass=cfg["nc_auth_pass"], nextcloud_url=url)
4543
return None
4644

4745

48-
def init_nc_by_app_pass(url, cfg) -> Optional[Nextcloud]:
46+
def init_nc_by_app_pass(url, cfg) -> Nextcloud | None:
4947
if cfg.get("nc_auth_user", "") and cfg.get("nc_auth_app_pass", ""):
5048
return Nextcloud(nc_auth_user=cfg["nc_auth_user"], nc_auth_pass=cfg["nc_auth_app_pass"], nextcloud_url=url)
5149
return None
5250

5351

54-
def init_nc_app(url, cfg) -> Optional[NextcloudApp]:
52+
def init_nc_app(url, cfg) -> NextcloudApp | None:
5553
if cfg.get("secret", "") and cfg.get("app_id", ""):
5654
return NextcloudApp(
5755
app_id=cfg["app_id"],

nc_py_api/_misc.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
import secrets
77
from base64 import b64decode
8+
from collections.abc import Callable
89
from datetime import datetime, timezone
910
from string import ascii_letters, digits
10-
from typing import Callable, Union
1111

1212
from ._exceptions import NextcloudMissingCapabilities
1313

@@ -28,7 +28,7 @@ def clear_from_params_empty(keys: list[str], params: dict) -> None:
2828
params.pop(key)
2929

3030

31-
def require_capabilities(capabilities: Union[str, list[str]], srv_capabilities: dict) -> None:
31+
def require_capabilities(capabilities: str | list[str], srv_capabilities: dict) -> None:
3232
"""Checks for capabilities and raises an exception if any of them are missing."""
3333
result = check_capabilities(capabilities, srv_capabilities)
3434
if result:
@@ -52,7 +52,7 @@ def __check_sub_capability(split_capabilities: list[str], srv_capabilities: dict
5252
return True
5353

5454

55-
def check_capabilities(capabilities: Union[str, list[str]], srv_capabilities: dict) -> list[str]:
55+
def check_capabilities(capabilities: str | list[str], srv_capabilities: dict) -> list[str]:
5656
"""Checks for capabilities and returns a list of missing ones."""
5757
if isinstance(capabilities, str):
5858
capabilities = [capabilities]

nc_py_api/_preferences_ex.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""Nextcloud API for working with apps V2's storage w/wo user context(table oc_appconfig_ex/oc_preferences_ex)."""
22

33
import dataclasses
4-
import typing
54

65
from ._exceptions import NextcloudExceptionNotFound
76
from ._misc import require_capabilities
@@ -26,7 +25,7 @@ class _BasicAppCfgPref:
2625
def __init__(self, session: NcSessionBasic):
2726
self._session = session
2827

29-
def get_value(self, key: str, default=None) -> typing.Optional[str]:
28+
def get_value(self, key: str, default=None) -> str | None:
3029
"""Returns the value of the key, if found, or the specified default value."""
3130
if not key:
3231
raise ValueError("`key` parameter can not be empty")
@@ -47,7 +46,7 @@ def get_values(self, keys: list[str]) -> list[CfgRecord]:
4746
results = self._session.ocs("POST", f"{self._session.ae_url}/{self._url_suffix}/get-values", json=data)
4847
return [CfgRecord(i) for i in results]
4948

50-
def delete(self, keys: typing.Union[str, list[str]], not_fail=True) -> None:
49+
def delete(self, keys: str | list[str], not_fail=True) -> None:
5150
"""Deletes config/preference entries by the provided keys."""
5251
if isinstance(keys, str):
5352
keys = [keys]
@@ -82,7 +81,7 @@ class AppConfigExAPI(_BasicAppCfgPref):
8281

8382
_url_suffix = "ex-app/config"
8483

85-
def set_value(self, key: str, value: str, sensitive: typing.Optional[bool] = None) -> None:
84+
def set_value(self, key: str, value: str, sensitive: bool | None = None) -> None:
8685
"""Sets a value and if specified the sensitive flag for a key.
8786
8887
.. note:: A sensitive flag ensures key values are truncated in Nextcloud logs.

nc_py_api/_session.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ class ServerVersion(typing.TypedDict):
4949
@dataclass
5050
class RuntimeOptions:
5151
xdebug_session: str
52-
timeout: typing.Optional[int]
53-
timeout_dav: typing.Optional[int]
54-
_nc_cert: typing.Union[str, bool]
52+
timeout: int | None
53+
timeout_dav: int | None
54+
_nc_cert: str | bool
5555
upload_chunk_v2: bool
5656

5757
def __init__(self, **kwargs):
@@ -62,7 +62,7 @@ def __init__(self, **kwargs):
6262
self.upload_chunk_v2 = kwargs.get("chunked_upload_v2", options.CHUNKED_UPLOAD_V2)
6363

6464
@property
65-
def nc_cert(self) -> typing.Union[str, bool]:
65+
def nc_cert(self) -> str | bool:
6666
return self._nc_cert
6767

6868

@@ -158,9 +158,9 @@ def ocs(
158158
method: str,
159159
path: str,
160160
*,
161-
content: typing.Optional[typing.Union[bytes, str, typing.Iterable[bytes], typing.AsyncIterable[bytes]]] = None,
162-
json: typing.Optional[typing.Union[dict, list]] = None,
163-
params: typing.Optional[dict] = None,
161+
content: bytes | str | typing.Iterable[bytes] | typing.AsyncIterable[bytes] | None = None,
162+
json: dict | list | None = None,
163+
params: dict | None = None,
164164
**kwargs,
165165
):
166166
self.init_adapter()

0 commit comments

Comments
 (0)