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/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 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 + 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/.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/.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/BambuPrinterManager.log.jsonl b/BambuPrinterManager.log.jsonl deleted file mode 100644 index e69de29..0000000 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..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"] 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