From f1e865530104eace0dceb0c34ad0eff0b5ab806c Mon Sep 17 00:00:00 2001 From: "Shell M. Shrader" Date: Tue, 11 Nov 2025 20:28:29 -0500 Subject: [PATCH 01/11] chore: add Python linting (black,isort,flake8,pylint,pre-commit) and CI --- pyproject.toml | 50 ++++++++++++++------------------------------------ 1 file changed, 14 insertions(+), 36 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 88ca793..6b506bd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,36 +1,14 @@ -[build-system] -# requires = ["setuptools"] -requires = ["setuptools == 76.1.0"] -build-backend = "setuptools.build_meta" - -[tool.setuptools.packages.find] -where = ["src/"] -exclude = ["bpm/ftpsclient"] - -[tool.setuptools.package-data] -"bpm" = ["*.json"] - -[project] -name = "bambu-printer-manager" -version = "0.4.5" -authors = [ - { name="Shell M. Shrader", email="shell@shellware.com" }, -] -description = "A pure python library for managing Bambu Labs printers" -readme = "README.md" -requires-python = ">=3.12.1" -classifiers = [ - "Programming Language :: Python :: 3", - "License :: Freely Distributable", - "Operating System :: OS Independent", -] -dependencies = [ - "webcolors", - "paho-mqtt", - "mkdocstrings[python]>=0.18", -] - -[project.urls] -Homepage = "https://github.com/synman/bambu-printer-manager" -Documentation = "https://synman.github.io/bambu-printer-manager/" -Issues = "https://github.com/synman/bambu-printer-manager/issues" \ No newline at end of file +[tool.black] +line-length = 100 +target-version = ['py311'] +include = '\.pyi?$' +exclude = ''' +/( + \.git + | \.venv + | venv + | build + | dist + | __pycache__ +)/ +''' \ No newline at end of file From e45a88dbea392da9f624ebec3d64501c146bd1a1 Mon Sep 17 00:00:00 2001 From: "Shell M. Shrader" Date: Tue, 11 Nov 2025 20:47:43 -0500 Subject: [PATCH 02/11] updated pyproject.toml --- pyproject.toml | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 6b506bd..1b4345b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,10 @@ +[build-system] +requires = ["setuptools == 76.1.0"] +build-backend = "setuptools.build_meta" + [tool.black] line-length = 100 -target-version = ['py311'] +target-version = ['py312'] include = '\.pyi?$' exclude = ''' /( @@ -11,4 +15,41 @@ exclude = ''' | dist | __pycache__ )/ -''' \ No newline at end of file +''' + +[tool.isort] +profile = "black" +line_length = 100 +known_third_party = ["pytest"] + +[tool.setuptools.packages.find] +where = ["src/"] +exclude = ["bpm/ftpsclient"] + +[tool.setuptools.package-data] +"bpm" = ["*.json"] + +[project] +name = "bambu-printer-manager" +version = "0.4.5" +authors = [ + { name="Shell M. Shrader", email="shell@shellware.com" }, +] +description = "A pure python library for managing Bambu Labs printers" +readme = "README.md" +requires-python = ">=3.12.1" +classifiers = [ + "Programming Language :: Python :: 3", + "License :: Freely Distributable", + "Operating System :: OS Independent", +] +dependencies = [ + "webcolors", + "paho-mqtt", + "mkdocstrings[python]>=0.18", +] + +[project.urls] +Homepage = "https://github.com/synman/bambu-printer-manager" +Documentation = "https://synman.github.io/bambu-printer-manager/" +Issues = "https://github.com/synman/bambu-printer-manager/issues" \ No newline at end of file From 5e79c12b5243e861ec0499bc942c5512707f8dae Mon Sep 17 00:00:00 2001 From: "Shell M. Shrader" Date: Tue, 11 Nov 2025 21:38:38 -0500 Subject: [PATCH 03/11] Remove BambuPrinterManager.log.jsonl and ignore it --- BambuPrinterManager.log.jsonl | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 BambuPrinterManager.log.jsonl diff --git a/BambuPrinterManager.log.jsonl b/BambuPrinterManager.log.jsonl deleted file mode 100644 index e69de29..0000000 From aa8a70d61618e46f655d914b976d31cabe84f213 Mon Sep 17 00:00:00 2001 From: "Shell M. Shrader" Date: Tue, 11 Nov 2025 21:40:24 -0500 Subject: [PATCH 04/11] Remove BambuPrinterManager.log.jsonl and ignore it --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 40d0890..16e6141 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ .env.production.local ._* BambuPrinter.log.* +BambuPrinterManager.log.* /node_modules /.pnp .pnp.js From 32f9f47cfd1fb039487068a233a2c497250ab8fb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 12 Nov 2025 02:43:12 +0000 Subject: [PATCH 05/11] Initial plan From c090650db48979ae0c86d1c9714af10b88aea069 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 12 Nov 2025 02:46:11 +0000 Subject: [PATCH 06/11] Add Python linting and formatting toolchain configuration Co-authored-by: synman <1299716+synman@users.noreply.github.com> --- .flake8 | 15 +++++++++++ .github/workflows/lint.yml | 51 ++++++++++++++++++++++++++++++++++++++ .pre-commit-config.yaml | 31 +++++++++++++++++++++++ .pylintrc | 17 +++++++++++++ Makefile | 38 ++++++++++++++++++++++++++++ pyproject.toml | 30 +++++++++++++++++++++- requirements-dev.txt | 5 ++++ 7 files changed, 186 insertions(+), 1 deletion(-) create mode 100644 .flake8 create mode 100644 .github/workflows/lint.yml create mode 100644 .pre-commit-config.yaml create mode 100644 .pylintrc create mode 100644 Makefile create mode 100644 requirements-dev.txt diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..40a5cae --- /dev/null +++ b/.flake8 @@ -0,0 +1,15 @@ +[flake8] +max-line-length = 100 +ignore = E203, W503 +exclude = + .git, + __pycache__, + .venv, + venv, + build, + dist, + *.egg-info, + .tox, + .eggs, + node_modules, + site diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..e62376c --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,51 @@ +name: Lint + +on: + push: + branches: + - devel + - main + - 'linting-*' + pull_request: + branches: + - devel + - main + +jobs: + lint: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ['3.12'] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements-dev.txt + + - name: Run Black (check) + run: black --check . + + - name: Run isort (check) + run: isort --check-only . + + - name: Run Flake8 + run: flake8 . + + - name: Run Pylint (optional) + continue-on-error: true + run: pylint src/ + + - name: Run pre-commit checks + run: | + pre-commit install + pre-commit run --all-files diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..b084f43 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,31 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files + - id: check-merge-conflict + - id: mixed-line-ending + + - repo: https://github.com/psf/black + rev: 24.1.1 + hooks: + - id: black + + - repo: https://github.com/pycqa/isort + rev: 5.13.2 + hooks: + - id: isort + + - repo: https://github.com/pycqa/flake8 + rev: 7.0.0 + hooks: + - id: flake8 + + - repo: https://github.com/pycqa/pylint + rev: v3.0.3 + hooks: + - id: pylint + args: [--rcfile=.pylintrc] diff --git a/.pylintrc b/.pylintrc new file mode 100644 index 0000000..bfd2c61 --- /dev/null +++ b/.pylintrc @@ -0,0 +1,17 @@ +[MASTER] +jobs=0 + +[MESSAGES CONTROL] +disable= + missing-module-docstring, + missing-class-docstring, + missing-function-docstring, + too-few-public-methods, + too-many-instance-attributes, + too-many-arguments, + too-many-locals, + too-many-branches, + too-many-statements + +[FORMAT] +max-line-length=100 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..902b6b2 --- /dev/null +++ b/Makefile @@ -0,0 +1,38 @@ +.PHONY: help lint lint-fix format precommit-install + +help: + @echo "Available targets:" + @echo " lint - Run all linters (black check, isort check, flake8)" + @echo " lint-fix - Run linters and fix issues (black, isort)" + @echo " format - Auto-format code with black and isort" + @echo " precommit-install - Install pre-commit hooks" + +lint: + @echo "Running Black (check only)..." + black --check . + @echo "Running isort (check only)..." + isort --check-only . + @echo "Running Flake8..." + flake8 . + @echo "Lint checks complete!" + +lint-fix: + @echo "Running Black..." + black . + @echo "Running isort..." + isort . + @echo "Running Flake8..." + flake8 . + @echo "Lint fixes complete!" + +format: + @echo "Formatting with Black..." + black . + @echo "Formatting with isort..." + isort . + @echo "Formatting complete!" + +precommit-install: + @echo "Installing pre-commit hooks..." + pre-commit install + @echo "Pre-commit hooks installed!" diff --git a/pyproject.toml b/pyproject.toml index 88ca793..67b763c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,4 +33,32 @@ dependencies = [ [project.urls] Homepage = "https://github.com/synman/bambu-printer-manager" Documentation = "https://synman.github.io/bambu-printer-manager/" -Issues = "https://github.com/synman/bambu-printer-manager/issues" \ No newline at end of file +Issues = "https://github.com/synman/bambu-printer-manager/issues" + +[tool.black] +line-length = 100 +target-version = ['py312'] +include = '\.pyi?$' +extend-exclude = ''' +/( + # directories + \.eggs + | \.git + | \.hg + | \.mypy_cache + | \.tox + | \.venv + | venv + | build + | dist + | node_modules + | site +)/ +''' + +[tool.isort] +profile = "black" +line_length = 100 +skip_gitignore = true +known_first_party = ["bpm"] +sections = ["FUTURE", "STDLIB", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER"] \ No newline at end of file diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..9377ce7 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,5 @@ +black>=24.0.0 +isort>=5.13.0 +flake8>=7.0.0 +pylint>=3.0.0 +pre-commit>=3.6.0 From 24e7f19c13a11c503665716808eba2c5fda5b772 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 12 Nov 2025 02:49:00 +0000 Subject: [PATCH 07/11] Incorporate changes from linting-setup: update .gitignore and pyproject.toml structure Co-authored-by: synman <1299716+synman@users.noreply.github.com> --- .gitignore | 1 + BambuPrinterManager.log.jsonl | 0 pyproject.toml | 52 +++++++++++++++-------------------- 3 files changed, 23 insertions(+), 30 deletions(-) delete mode 100644 BambuPrinterManager.log.jsonl diff --git a/.gitignore b/.gitignore index 40d0890..16e6141 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ .env.production.local ._* BambuPrinter.log.* +BambuPrinterManager.log.* /node_modules /.pnp .pnp.js diff --git a/BambuPrinterManager.log.jsonl b/BambuPrinterManager.log.jsonl deleted file mode 100644 index e69de29..0000000 diff --git a/pyproject.toml b/pyproject.toml index 67b763c..dc86990 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,8 +1,28 @@ [build-system] -# requires = ["setuptools"] requires = ["setuptools == 76.1.0"] build-backend = "setuptools.build_meta" +[tool.black] +line-length = 100 +target-version = ['py312'] +include = '\.pyi?$' +exclude = ''' +/( + \.git + | \.venv + | venv + | build + | dist + | __pycache__ +)/ +''' + +[tool.isort] +profile = "black" +line_length = 100 +known_first_party = ["bpm"] +known_third_party = ["pytest"] + [tool.setuptools.packages.find] where = ["src/"] exclude = ["bpm/ftpsclient"] @@ -33,32 +53,4 @@ dependencies = [ [project.urls] Homepage = "https://github.com/synman/bambu-printer-manager" Documentation = "https://synman.github.io/bambu-printer-manager/" -Issues = "https://github.com/synman/bambu-printer-manager/issues" - -[tool.black] -line-length = 100 -target-version = ['py312'] -include = '\.pyi?$' -extend-exclude = ''' -/( - # directories - \.eggs - | \.git - | \.hg - | \.mypy_cache - | \.tox - | \.venv - | venv - | build - | dist - | node_modules - | site -)/ -''' - -[tool.isort] -profile = "black" -line_length = 100 -skip_gitignore = true -known_first_party = ["bpm"] -sections = ["FUTURE", "STDLIB", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER"] \ No newline at end of file +Issues = "https://github.com/synman/bambu-printer-manager/issues" \ No newline at end of file From bec86a42f3732e2dc673ed5c78185bfe2d4d15b3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 12 Nov 2025 04:20:40 +0000 Subject: [PATCH 08/11] Initial plan From d6327fdaec662e55e8b78b8f7152b6cb2d83fda2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 12 Nov 2025 04:24:19 +0000 Subject: [PATCH 09/11] Add PR template with linting requirements checklist Co-authored-by: synman <1299716+synman@users.noreply.github.com> --- .github/PULL_REQUEST_TEMPLATE.md | 39 ++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..a8914d4 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,39 @@ +## Description + + +## Type of Change + +- [ ] Bug fix (non-breaking change which fixes an issue) +- [ ] New feature (non-breaking change which adds functionality) +- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) +- [ ] Documentation update +- [ ] Code refactoring +- [ ] Performance improvement +- [ ] Other (please describe): + +## Related Issues + + +## Testing + +- [ ] Tested locally +- [ ] Added/updated unit tests +- [ ] All existing tests pass + +## Code Quality Checklist + +- [ ] Code passes Black formatting check (`black --check .`) +- [ ] Code passes isort import sorting check (`isort --check-only .`) +- [ ] Code passes Flake8 linting (`flake8 .`) +- [ ] Code passes Pylint checks (or documented why warnings are acceptable) +- [ ] Pre-commit hooks installed and passing (`pre-commit run --all-files`) +- [ ] CI workflow (lint.yml) passes successfully + +## Documentation + +- [ ] Code is self-documenting and/or includes necessary comments +- [ ] README.md updated (if needed) +- [ ] Documentation updated (if needed) + +## Additional Notes + From 014959c0b110bb7baab3547a6198f7763c3712da Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 12 Nov 2025 04:33:03 +0000 Subject: [PATCH 10/11] Initial plan From d6977c1deb56d83ea43f6ba8f0d5ba8e96cb4dc1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 12 Nov 2025 04:41:04 +0000 Subject: [PATCH 11/11] Merge add-issue-templates branch: Add standard issue templates Co-authored-by: synman <1299716+synman@users.noreply.github.com> --- .github/ISSUE_TEMPLATE/bug_report.md | 37 +++++++++++++++++++++++ .github/ISSUE_TEMPLATE/config.yml | 5 +++ .github/ISSUE_TEMPLATE/feature_request.md | 24 +++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/config.yml create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..f0ea25a --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,37 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '[BUG] ' +labels: bug +assignees: '' +--- + +## Bug report + +**Summary** +A short summary of the problem. + +**Steps to reproduce** +1. Step one to reproduce +2. Step two +3. ... + +**Expected behavior** +What you expected to happen. + +**Actual behavior** +What actually happened (include error messages / stack traces if available). + +**Reproduction code / example** +If possible, provide a minimal code snippet or steps to reproduce. + +**Environment** +- bambu-printer-manager version: (e.g. 0.4.5) +- Python version: (e.g. 3.12) +- OS: (e.g. macOS 14.1, Ubuntu 24.04) + +**Logs** +If applicable, paste relevant logs or attach files. + +**Additional context** +Anything else that might help us debug (screenshots, sample files, printer firmware version, etc.) \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..5167acc --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,5 @@ +blank_issues_enabled: false +contact_links: + - name: "Support / Questions" + url: "https://github.com/synman/bambu-printer-manager/discussions" + about: "General questions and support requests" \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..748e701 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,24 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '[FEATURE] ' +labels: enhancement +assignees: '' +--- + +## Feature request + +**Problem** +Describe the problem or the user need this feature would solve. + +**Proposed solution** +Describe the proposed change or API. Prefer short examples showing how developers would use it. + +**Why is this important** +Describe the impact and the primary users (e.g., local users, CI automation). + +**Alternatives considered** +Other approaches you considered (and why they were not chosen). + +**Additional context** +Links to related issues, PRs, or design notes. \ No newline at end of file