88 lines
3.1 KiB
Diff
88 lines
3.1 KiB
Diff
From 1eac94954530a1dca2c498de7bf9f92ee12479b1 Mon Sep 17 00:00:00 2001
|
|
From: kkalinowski-reef <114084217+kkalinowski-reef@users.noreply.github.com>
|
|
Date: Tue, 15 Nov 2022 01:11:34 +0100
|
|
Subject: [PATCH] Fetching command class from parsed arguments instead of
|
|
registry (#836)
|
|
|
|
* Fetching command class from parsed arguments instead of registry
|
|
|
|
* Enabled 3.11 tests in both nox and github workflows
|
|
---
|
|
.github/workflows/ci.yml | 2 +-
|
|
CHANGELOG.md | 1 +
|
|
b2/console_tool.py | 11 ++++++-----
|
|
noxfile.py | 8 +++++++-
|
|
4 files changed, 15 insertions(+), 7 deletions(-)
|
|
|
|
[Void note (ahesford): CHANGLEOG.md diff conflicts and was dropped.]
|
|
|
|
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
|
|
index 5d64cdb5..84932867 100644
|
|
--- a/.github/workflows/ci.yml
|
|
+++ b/.github/workflows/ci.yml
|
|
@@ -80,7 +80,7 @@ jobs:
|
|
fail-fast: false
|
|
matrix:
|
|
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
|
|
- python-version: ["3.7", "3.8", "3.9", "3.10", "pypy-3.7"]
|
|
+ python-version: ["3.7", "3.8", "3.9", "3.10", "pypy-3.7", "3.11"]
|
|
exclude:
|
|
- os: "macos-latest"
|
|
python-version: "pypy-3.7"
|
|
diff --git a/b2/console_tool.py b/b2/console_tool.py
|
|
index 1115cc79..760be547 100644
|
|
--- a/b2/console_tool.py
|
|
+++ b/b2/console_tool.py
|
|
@@ -500,11 +500,8 @@ def name_and_alias(cls):
|
|
@classmethod
|
|
def register_subcommand(cls, command_class):
|
|
assert cls.subcommands_registry is not None, 'Initialize the registry class'
|
|
- name, alias = command_class.name_and_alias()
|
|
+ name, _ = command_class.name_and_alias()
|
|
decorator = cls.subcommands_registry.register(key=name)(command_class)
|
|
- # Register alias if present
|
|
- if alias is not None:
|
|
- cls.subcommands_registry[alias] = command_class
|
|
return decorator
|
|
|
|
@classmethod
|
|
@@ -531,6 +528,8 @@ def get_parser(cls, subparsers=None, parents=None, for_docs=False):
|
|
aliases=[alias] if alias is not None and not for_docs else (),
|
|
for_docs=for_docs,
|
|
)
|
|
+ # Register class that will handle this particular command, for both name and alias.
|
|
+ parser.set_defaults(command_class=cls)
|
|
|
|
cls._setup_parser(parser)
|
|
|
|
@@ -655,7 +654,9 @@ def name_and_alias(cls):
|
|
return NAME, None
|
|
|
|
def run(self, args):
|
|
- return self.subcommands_registry.get_class(args.command)
|
|
+ # Commands could be named via name or alias, so we fetch
|
|
+ # the command from args assigned during parser preparation.
|
|
+ return args.command_class
|
|
|
|
|
|
@B2.register_subcommand
|
|
diff --git a/noxfile.py b/noxfile.py
|
|
index aaa2bac3..25cf8de1 100644
|
|
--- a/noxfile.py
|
|
+++ b/noxfile.py
|
|
@@ -24,7 +24,13 @@
|
|
NO_STATICX = os.environ.get('NO_STATICX') is not None
|
|
NOX_PYTHONS = os.environ.get('NOX_PYTHONS')
|
|
|
|
-PYTHON_VERSIONS = ['3.7', '3.8', '3.9', '3.10'] if NOX_PYTHONS is None else NOX_PYTHONS.split(',')
|
|
+PYTHON_VERSIONS = [
|
|
+ '3.7',
|
|
+ '3.8',
|
|
+ '3.9',
|
|
+ '3.10',
|
|
+ '3.11',
|
|
+] if NOX_PYTHONS is None else NOX_PYTHONS.split(',')
|
|
PYTHON_DEFAULT_VERSION = PYTHON_VERSIONS[-1]
|
|
|
|
PY_PATHS = ['b2', 'test', 'noxfile.py', 'setup.py']
|