Skip to content

Commit

Permalink
Merge pull request Backblaze#1052 from reef-technologies/py313
Browse files Browse the repository at this point in the history
python 3.13 support
  • Loading branch information
mjurbanski-reef authored Oct 28, 2024
2 parents f968d7b + 1bd37ad commit e02ed55
Show file tree
Hide file tree
Showing 10 changed files with 644 additions and 596 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:
fail-fast: false
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "pypy3.9", "pypy3.10"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "pypy3.9", "pypy3.10"]
exclude:
- os: "macos-latest"
python-version: "pypy3.10"
Expand Down Expand Up @@ -126,7 +126,7 @@ jobs:
run: nox -vs integration -p ${{ matrix.python-version }} -- -m "not require_secrets"
- name: Run integration tests (with secrets)
# Limit CI workload by running integration tests with secrets only on edge Python versions.
if: ${{ env.B2_TEST_APPLICATION_KEY != '' && env.B2_TEST_APPLICATION_KEY_ID != '' && contains(fromJSON('["3.7", "pypy3.10", "3.12"]'), matrix.python-version) }}
if: ${{ env.B2_TEST_APPLICATION_KEY != '' && env.B2_TEST_APPLICATION_KEY_ID != '' && contains(fromJSON('["3.8", "pypy3.10", "3.13"]'), matrix.python-version) }}
run: nox -vs integration -p ${{ matrix.python-version }} -- -m "require_secrets" --cleanup
test-docker:
timeout-minutes: 90
Expand Down
11 changes: 7 additions & 4 deletions b2/_internal/arg_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def add_argument(self, action):
col_length = max(len(choice.prog) for choice in action.choices.values())

for choice in action.choices.values():
deprecated = getattr(choice, 'deprecated', False)
deprecated = getattr(choice, 'deprecated', None)
if deprecated:
if self.show_all:
usages.append(f'(DEPRECATED) {choice.format_usage()}')
Expand Down Expand Up @@ -86,18 +86,21 @@ def __init__(
*args,
add_help_all: bool = True,
for_docs: bool = False,
deprecated: bool = False,
custom_deprecated: bool = False,
**kwargs
):
"""
Parameter `deprecated` was renamed to `custom_deprecated` to avoid conflict with `deprecated` parameter
introduced in Python 3.13.
:param for_docs: is this parser used for generating docs
:param deprecated: is this option deprecated
:param custom_deprecated: is this command deprecated?
"""
self._raw_description = None
self._description = None
self._for_docs = for_docs
self.deprecated = deprecated
self.deprecated = custom_deprecated
self._short_description = self._make_short_description(
kwargs.get('usage', ''), kwargs.get('description', '')
)
Expand Down
2 changes: 1 addition & 1 deletion b2/_internal/console_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,7 @@ def create_parser(
description=description,
parents=parents,
for_docs=for_docs,
deprecated=cls.deprecated,
custom_deprecated=cls.deprecated,
)

if subparsers is None:
Expand Down
2 changes: 2 additions & 0 deletions changelog.d/+official_python313_support.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Declare official support for Python 3.13 in `b2` CLI.
Test `b2` CLI against Python 3.13 in CI.
3 changes: 2 additions & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
'3.10',
'3.11',
'3.12',
'3.13',
] if NOX_PYTHONS is None else NOX_PYTHONS.split(',')


Expand All @@ -56,7 +57,7 @@ def _detect_python_nox_id() -> str:
PYTHON_VERSIONS = [_detect_python_nox_id()]
print(f"CI job mode; using provided interpreter only; PYTHON_VERSIONS={PYTHON_VERSIONS!r}")

PYTHON_DEFAULT_VERSION = PYTHON_VERSIONS[-1]
PYTHON_DEFAULT_VERSION = PYTHON_VERSIONS[-2] if len(PYTHON_VERSIONS) > 1 else PYTHON_VERSIONS[0]

PY_PATHS = ['b2', 'test', 'noxfile.py']

Expand Down
1,185 changes: 613 additions & 572 deletions pdm.lock

Large diffs are not rendered by default.

25 changes: 13 additions & 12 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ classifiers = [
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
]
dependencies = [
"argcomplete>=2,<4",
"arrow>=1.0.2,<2.0.0",
"b2sdk>=2.5.1,<3",
"b2sdk>=2.6.0,<3",
"docutils>=0.18.1",
"idna~=3.4; platform_system == 'Java'",
"importlib-metadata>=3.3; python_version < '3.8'",
Expand All @@ -41,18 +42,18 @@ dependencies = [
# requirements. They should be removed from this section when
# a breaking version is released.
doc = [
"sadisplay>=0.4.9; python_version>='3.9'",
"sphinx>=7.2,<8; python_version>='3.9'",
"sphinx-argparse; python_version>='3.9'",
"sphinx-autobuild; python_version>='3.9'",
"sphinx-rtd-theme>=1.3,<2; python_version>='3.9'",
"sphinxcontrib-plantuml; python_version>='3.9'"
"sadisplay>=0.4.9; python_version >= '3.9'",
"sphinx>=7.2,<8; python_version >= '3.9'",
"sphinx-argparse; python_version >= '3.9'",
"sphinx-autobuild; python_version >= '3.9'",
"sphinx-rtd-theme>=1.3,<2; python_version >= '3.9'",
"sphinxcontrib-plantuml; python_version >= '3.9'"
]
license = [
"pip>=23.1.0,<24",
"pip>=23.1.0",
"pip-licenses==3.5.5; python_version < '3.9'",
"pip-licenses~=4.3.3; python_version >= '3.9'",
"pipdeptree>=2.9,<3; python_version>='3.9'",
"pip-licenses~=5.0; python_version >= '3.9'",
"pipdeptree>=2.9,<3; python_version >= '3.9'",
"prettytable~=3.7; python_version < '3.9'",
"prettytable~=3.9; python_version >= '3.9'",
]
Expand Down Expand Up @@ -191,11 +192,11 @@ lint = [
"yapf==0.27",
"ruff==0.0.272",
"pytest==6.2.5",
"liccheck==0.9.2",
"liccheck>=0.9.2",
"setuptools>=60", # required by liccheck
]
release = [
"towncrier==23.11.0; python_version>='3.8'",
"towncrier==23.11.0; python_version >= '3.8'",
]
test = [
"coverage==7.2.7",
Expand Down
2 changes: 1 addition & 1 deletion test/integration/test_b2_command_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -1954,7 +1954,7 @@ def test_sse_c(


@pytest.mark.skipif(
(sys.version_info.major, sys.version_info.minor) < (3, 8),
(sys.version_info.major, sys.version_info.minor) < (3, 9),
reason="License extraction doesn't work on older versions, and we're only "
"obliged to provide this "
"data in bundled and built packages."
Expand Down
2 changes: 1 addition & 1 deletion test/integration/test_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ def test_help(cli_version):
if platform.system() == 'Windows':
expected_name += '.exe'
assert re.match(r"^_?b2(v\d+)?(\.exe)?$", expected_name) # test sanity check
assert f" {expected_name} <command> --help" in p.stdout
assert f"{expected_name} <command> --help" in p.stdout
4 changes: 2 additions & 2 deletions test/unit/_cli/test_autocomplete_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,12 @@ def test_pickle_store(tmp_path):
store.set_pickle('test_1', b'test_data_1')
assert store.get_pickle('test_1') == b'test_data_1'
assert store.get_pickle('test_2') is None
assert len(list(dir.glob('**'))) == 1
assert len(list(dir.rglob('*.pickle'))) == 1

store.set_pickle('test_2', b'test_data_2')
assert store.get_pickle('test_2') == b'test_data_2'
assert store.get_pickle('test_1') is None
assert len(list(dir.glob('**'))) == 1
assert len(list(dir.rglob('*.pickle'))) == 1


class Unpickler(pickle.Unpickler):
Expand Down

0 comments on commit e02ed55

Please sign in to comment.