From 46c3530da5936b5fb12b182adda6d4e458f1a8c4 Mon Sep 17 00:00:00 2001 From: zvecr Date: Wed, 3 Jun 2026 14:08:43 +0100 Subject: [PATCH 1/6] Migrate project to pyproject.toml --- .bumpversion.cfg | 2 +- .flake8 | 6 ++ pyproject.toml | 113 ++++++++++++++++++++++++++++++-- qmk | 1 + qmk_cli/helpers.py | 4 +- qmk_cli/script_qmk.py | 6 +- qmk_cli/subcommands/__init__.py | 8 +-- qmk_cli/subcommands/setup.py | 2 +- setup.cfg | 108 ------------------------------ 9 files changed, 127 insertions(+), 123 deletions(-) create mode 100644 .flake8 delete mode 100644 setup.cfg diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 1b593fe..2898141 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -9,4 +9,4 @@ message = New release: {current_version} → {new_version} [bumpversion:file:qmk_cli/__init__.py] -[bumpversion:file:setup.cfg] +[bumpversion:file:pyproject.toml] diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..a7f7ecf --- /dev/null +++ b/.flake8 @@ -0,0 +1,6 @@ +[flake8] +ignore = E501 +exclude = + __pycache__ + .direnv + .env diff --git a/pyproject.toml b/pyproject.toml index 374b58c..8d1a0f6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,111 @@ [build-system] -requires = [ - "setuptools>=42", - "wheel" -] +requires = ["setuptools>=82.0.1"] build-backend = "setuptools.build_meta" + +[project] +name = "qmk" +version = "1.2.0" +license = {text = "MIT"} +readme = "README.md" +authors = [{name = "skullydazed", email = "skullydazed@gmail.com"}] +description = "A program to help users work with QMK Firmware." +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Environment :: Console", + "Intended Audience :: Developers", + "Intended Audience :: System Administrators", + "Intended Audience :: End Users/Desktop", + "Natural Language :: English", + "Programming Language :: Python :: 3 :: Only", + "Topic :: Scientific/Engineering", + "Topic :: Software Development", + "Topic :: Utilities", +] +requires-python = ">=3.9" +dependencies = [ + "hid", + "milc>=1.9.0", + "platformdirs", + "pyusb", + # qmk_firmware packages + "dotty-dict", + "hjson", + "jsonschema>=4", + "pillow", + "pygments", + "pyserial", +] + +[project.urls] +"Bug Tracker" = "https://github.com/qmk/qmk_cli/issues" +Documentation = "https://docs.qmk.fm/cli" +Homepage = "https://qmk.fm/" +Source = "https://github.com/qmk/qmk_cli/" + +[project.scripts] +qmk = "qmk_cli.script_qmk:main" + +[tool.setuptools] +include-package-data = false + +[tool.setuptools.packages] +find = {namespaces = false} + +[tool.yapfignore] +ignore_patterns = [ + ".direnv/**/*", + ".env/**/*", +] + +[tool.yapf] +align_closing_bracket_with_visual_indent = true +allow_multiline_dictionary_keys = false +allow_multiline_lambdas = false +allow_split_before_default_or_named_assigns = true +allow_split_before_dict_value = true +arithmetic_precedence_indication = true +blank_lines_around_top_level_definition = 2 +blank_line_before_class_docstring = false +blank_line_before_module_docstring = false +blank_line_before_nested_class_or_def = false +coalesce_brackets = true +column_limit = 256 +continuation_align_style = "SPACE" +continuation_indent_width = 4 +dedent_closing_brackets = true +disable_ending_comma_heuristic = false +each_dict_entry_on_separate_line = true +i18n_comment = "" +i18n_function_call = "" +indent_blank_lines = false +indent_dictionary_value = true +indent_width = 4 +join_multiple_lines = false +no_spaces_around_selected_binary_operators = "" +spaces_around_default_or_named_assign = false +spaces_around_power_operator = false +spaces_before_comment = 2 +space_between_ending_comma_and_closing_bracket = false +split_all_comma_separated_values = false +split_arguments_when_comma_terminated = true +split_before_arithmetic_operator = false +split_before_bitwise_operator = true +split_before_closing_bracket = true +split_before_dict_set_generator = true +split_before_dot = false +split_before_expression_after_opening_paren = false +split_before_first_argument = false +split_before_logical_operator = false +split_before_named_assigns = true +split_complex_comprehension = true +split_penalty_after_opening_bracket = 300 +split_penalty_after_unary_operator = 10000 +split_penalty_arithmetic_operator = 300 +split_penalty_before_if_expr = 0 +split_penalty_bitwise_operator = 300 +split_penalty_comprehension = 80 +split_penalty_excess_character = 7000 +split_penalty_for_added_line_split = 30 +split_penalty_import_names = 0 +split_penalty_logical_operator = 300 +use_tabs = false diff --git a/qmk b/qmk index 92c039f..2cbaae4 100755 --- a/qmk +++ b/qmk @@ -2,4 +2,5 @@ """Wrapper to call the qmk cli script entrypoint. """ import qmk_cli.script_qmk + qmk_cli.script_qmk.main() diff --git a/qmk_cli/helpers.py b/qmk_cli/helpers.py index 8abc757..775fd1c 100644 --- a/qmk_cli/helpers.py +++ b/qmk_cli/helpers.py @@ -26,7 +26,7 @@ def is_qmk_firmware(qmk_firmware): qmk_firmware / 'quantum', qmk_firmware / 'requirements.txt', qmk_firmware / 'requirements-dev.txt', - qmk_firmware / 'lib/python/qmk/cli/__init__.py' + qmk_firmware / 'lib/python/qmk/cli/__init__.py', ] for path in paths: @@ -80,7 +80,7 @@ def is_qmk_userspace(qmk_userspace): try: return 'userspace_version' in json.loads(path.read_text(encoding="UTF-8")) - except json.decoder.JSONDecodeError as e: + except json.decoder.JSONDecodeError: return False diff --git a/qmk_cli/script_qmk.py b/qmk_cli/script_qmk.py index 39c17f5..e4a22fc 100644 --- a/qmk_cli/script_qmk.py +++ b/qmk_cli/script_qmk.py @@ -43,7 +43,7 @@ def _get_default_distrib_path(): milc.EMOJI_LOGLEVELS['INFO'] = '{fg_blue}Ψ{style_reset_all}' # These must happen after the milc.milc_options() call -import milc.subcommand.config # noqa, must come after milc.milc_options() +import milc.subcommand.config # noqa: E402, must come after milc.milc_options() @milc.cli.entrypoint('CLI wrapper for running QMK commands.') @@ -83,7 +83,7 @@ def main(): os.environ['QMK_HOME'] = str(qmk_firmware) os.environ['ORIG_CWD'] = os.getcwd() - import qmk_cli.subcommands + import qmk_cli.subcommands # noqa: F401 # Check out and initialize the qmk_firmware environment if is_qmk_firmware(qmk_firmware): @@ -92,7 +92,7 @@ def main(): sys.path.append(str(qmk_firmware / 'lib/python')) try: - import qmk.cli # noqa + import qmk.cli # noqa: F401 except ImportError as e: if qmk_firmware.name != 'qmk_firmware': diff --git a/qmk_cli/subcommands/__init__.py b/qmk_cli/subcommands/__init__.py index 9ba4579..31ba2a2 100644 --- a/qmk_cli/subcommands/__init__.py +++ b/qmk_cli/subcommands/__init__.py @@ -2,7 +2,7 @@ We list each subcommand here explicitly because all the reliable ways of searching for modules are slow and delay startup. """ -from . import clone # noqa -from . import console # noqa -from . import env # noqa -from . import setup # noqa +from . import clone # noqa: F401 +from . import console # noqa: F401 +from . import env # noqa: F401 +from . import setup # noqa: F401 diff --git a/qmk_cli/subcommands/setup.py b/qmk_cli/subcommands/setup.py index 87d5dee..fbc655c 100644 --- a/qmk_cli/subcommands/setup.py +++ b/qmk_cli/subcommands/setup.py @@ -82,7 +82,7 @@ def setup(cli): found_options = [ f"Delete and reclone {cli.args.fork}", "Delete and clone a different fork", - "Keep it and continue" + "Keep it and continue", ] delete_confirm = "WARNING: This will delete your current qmk_firmware directory. Proceed?" diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 3e5b4f3..0000000 --- a/setup.cfg +++ /dev/null @@ -1,108 +0,0 @@ -#[bumpversion] -# Bumpversion config has been moved to .bumpversion.cfg - -[bdist_wheel] -universal = 1 - -[flake8] -ignore = E501,E226 - -[metadata] -name = qmk -version = 1.2.0 -author = skullydazed -author_email = skullydazed@gmail.com -description = A program to help users work with QMK Firmware. -long_description = file: README.md -long_description_content_type = text/markdown -license = MIT License -project_urls = - Bug Tracker = https://github.com/qmk/qmk_cli/issues - Documentation = https://docs.qmk.fm/#/cli - Homepage = https://qmk.fm/ - Source = https://github.com/qmk/qmk_cli/ -classifiers = - Development Status :: 3 - Alpha - Environment :: Console - Intended Audience :: Developers - Intended Audience :: System Administrators - Intended Audience :: End Users/Desktop - License :: OSI Approved :: MIT License - Natural Language :: English - Programming Language :: Python :: 3 :: Only - Topic :: Scientific/Engineering - Topic :: Software Development - Topic :: Utilities - -[options] -install_requires = - hid - milc>=1.9.0 - platformdirs - pyusb - # qmk_firmware packages - dotty-dict - hjson - jsonschema>=4 - pillow - pygments - pyserial -packages = find: -python_requires = >=3.9 - -[options.entry_points] -console_scripts = - qmk = qmk_cli.script_qmk:main - -[yapf] -align_closing_bracket_with_visual_indent = True -allow_multiline_dictionary_keys = False -allow_multiline_lambdas = False -allow_split_before_default_or_named_assigns = True -allow_split_before_dict_value = True -arithmetic_precedence_indication = True -blank_lines_around_top_level_definition = 2 -blank_line_before_class_docstring = False -blank_line_before_module_docstring = False -blank_line_before_nested_class_or_def = False -coalesce_brackets = True -column_limit = 256 -continuation_align_style = SPACE -continuation_indent_width = 4 -dedent_closing_brackets = True -disable_ending_comma_heuristic = False -each_dict_entry_on_separate_line = True -i18n_comment = -i18n_function_call = -indent_blank_lines = False -indent_dictionary_value = True -indent_width = 4 -join_multiple_lines = False -no_spaces_around_selected_binary_operators = -spaces_around_default_or_named_assign = False -spaces_around_power_operator = False -spaces_before_comment = 2 -space_between_ending_comma_and_closing_bracket = False -split_all_comma_separated_values = False -split_arguments_when_comma_terminated = True -split_before_arithmetic_operator = False -split_before_bitwise_operator = True -split_before_closing_bracket = True -split_before_dict_set_generator = True -split_before_dot = False -split_before_expression_after_opening_paren = False -split_before_first_argument = False -split_before_logical_operator = False -split_before_named_assigns = True -split_complex_comprehension = True -split_penalty_after_opening_bracket = 300 -split_penalty_after_unary_operator = 10000 -split_penalty_arithmetic_operator = 300 -split_penalty_before_if_expr = 0 -split_penalty_bitwise_operator = 300 -split_penalty_comprehension = 80 -split_penalty_excess_character = 7000 -split_penalty_for_added_line_split = 30 -split_penalty_import_names = 0 -split_penalty_logical_operator = 300 -use_tabs = False From 79b417c9c8a9ef2fa2a329c783f860b401d94f72 Mon Sep 17 00:00:00 2001 From: zvecr Date: Wed, 3 Jun 2026 14:51:59 +0100 Subject: [PATCH 2/6] Add linters to dev deps --- pyproject.toml | 9 +++++++++ requirements-dev.txt | 2 ++ 2 files changed, 11 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 8d1a0f6..47cc123 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,6 +36,15 @@ dependencies = [ "pyserial", ] +[dependency-groups] +dev = [ + "build", + "bumpversion", + "flake8", + "twine", + "yapf", +] + [project.urls] "Bug Tracker" = "https://github.com/qmk/qmk_cli/issues" Documentation = "https://docs.qmk.fm/cli" diff --git a/requirements-dev.txt b/requirements-dev.txt index 407d6e6..8b89381 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,3 +1,5 @@ build bumpversion +flake8 twine +yapf From a792fa1e9ae115d9e2c1a3c51b9c4463f7cfe371 Mon Sep 17 00:00:00 2001 From: zvecr Date: Wed, 3 Jun 2026 15:00:04 +0100 Subject: [PATCH 3/6] Use 'pip install --group dev' instead of requirements-dev.txt --- .github/workflows/docker-pr.yml | 2 +- .github/workflows/python-publish.yml | 2 +- requirements-dev.txt | 5 ----- 3 files changed, 2 insertions(+), 7 deletions(-) delete mode 100644 requirements-dev.txt diff --git a/.github/workflows/docker-pr.yml b/.github/workflows/docker-pr.yml index 4582a8b..5d89c73 100644 --- a/.github/workflows/docker-pr.yml +++ b/.github/workflows/docker-pr.yml @@ -29,7 +29,7 @@ jobs: run: | python3 -m pip install --upgrade pip pip install setuptools wheel - pip install -r requirements-dev.txt + pip install --group dev - name: Build Python run: | diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index d9820ed..adce3ac 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -37,7 +37,7 @@ jobs: run: | python3 -m pip install --upgrade pip pip install setuptools wheel - pip install -r requirements-dev.txt + pip install --group dev - name: Bump version run: | diff --git a/requirements-dev.txt b/requirements-dev.txt deleted file mode 100644 index 8b89381..0000000 --- a/requirements-dev.txt +++ /dev/null @@ -1,5 +0,0 @@ -build -bumpversion -flake8 -twine -yapf From a3df604aa9ffc1dc51d37e6f17059ccc91ebb8df Mon Sep 17 00:00:00 2001 From: zvecr Date: Wed, 3 Jun 2026 15:00:32 +0100 Subject: [PATCH 4/6] Fix 'project.license' warning --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 47cc123..18de073 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta" [project] name = "qmk" version = "1.2.0" -license = {text = "MIT"} +license = "MIT" readme = "README.md" authors = [{name = "skullydazed", email = "skullydazed@gmail.com"}] description = "A program to help users work with QMK Firmware." From 38f89e113ba244e712b4ff8ddc00309999c779f4 Mon Sep 17 00:00:00 2001 From: zvecr Date: Wed, 3 Jun 2026 15:07:59 +0100 Subject: [PATCH 5/6] Use 'pip install --group dev' instead of requirements-dev.txt --- README.md | 2 +- ci_tests | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2cd0ec4..9043926 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ We follow PEP517, you can install using [build](https://pypi.org/project/build/) Setup: - python3 -m pip install build + python3 -m pip install --group dev Build: diff --git a/ci_tests b/ci_tests index 1078c30..f2b5c1e 100755 --- a/ci_tests +++ b/ci_tests @@ -31,7 +31,7 @@ source .ci_venv/bin/activate # Install dependencies python3 -m pip install -U pip wheel python3 -m pip install . -python3 -m pip install -r requirements-dev.txt +python3 -m pip install --group dev # Ensure that qmk works echo "*** Testing 'qmk clone -h'" From 806e1673799b10eec8a347731d1bba1657eed249 Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Wed, 3 Jun 2026 17:04:14 +0100 Subject: [PATCH 6/6] Remove dev group installation from ci_tests Removed installation of development group dependencies. --- ci_tests | 1 - 1 file changed, 1 deletion(-) diff --git a/ci_tests b/ci_tests index f2b5c1e..60963fb 100755 --- a/ci_tests +++ b/ci_tests @@ -31,7 +31,6 @@ source .ci_venv/bin/activate # Install dependencies python3 -m pip install -U pip wheel python3 -m pip install . -python3 -m pip install --group dev # Ensure that qmk works echo "*** Testing 'qmk clone -h'"