Conversation
# Conflicts:
# poetry.lock
# {{cookiecutter.project_slug}}/environment-dev.yml
# {{cookiecutter.project_slug}}/pyproject.toml
# {{cookiecutter.project_slug}}/requirements-dev.txt
6533cb3 to
4a544b0
Compare
# Conflicts:
# {{cookiecutter.project_slug}}/pyproject.toml
# {{cookiecutter.project_slug}}/requirements-dev.txt
There was a problem hiding this comment.
Pull request overview
This PR adds Ruff as a third code formatter option to the cookiecutter template, alongside the existing Black and none options. Ruff is a modern, fast Python linter and formatter that consolidates the functionality of multiple tools (Black, isort, pyupgrade, flake8) into a single tool.
Changes:
- Added Ruff as a selectable code formatter option in
cookiecutter.json - Integrated Ruff configuration across all package managers (Poetry, Conda, Pip, UV)
- Added GitLab CI linting jobs for Ruff across all package managers
- Updated dependency versions (JupyterLab 3.5 → 4.5.3, Ruff 0.1.7 → 0.12.2)
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| cookiecutter.json | Added "ruff" as a third option for code_formatter with descriptive prompt text |
| {{cookiecutter.project_slug}}/pyproject.toml | Added Ruff configuration blocks and updated conditional logic for tool selection |
| {{cookiecutter.project_slug}}/requirements-dev.txt | Added Ruff dependency for pip-based projects |
| {{cookiecutter.project_slug}}/environment-dev.yml | Added Ruff to conda dependencies with proper conditionals |
| {{cookiecutter.project_slug}}/.pre-commit-config.yaml | Added ruff-pre-commit hooks with format and check support |
| {{cookiecutter.project_slug}}/.gitlab-ci.yml | Added linter-happiness CI jobs for all package managers using Ruff |
| {{cookiecutter.project_slug}}/.vscode__editor/settings.json | Added VSCode configuration for Ruff extension |
| tests/test_options.py | Added comprehensive test coverage for Ruff across all package managers and CI scenarios |
| hooks/post_gen_project.py | Updated formatter validation to include 'ruff' option |
| CHANGELOG.md | Documented the new Ruff support feature and related changes |
| {{cookiecutter.project_slug}}/README.md | Fixed trailing whitespace |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| {%- endif %} | ||
| isort = "^5.12.0" | ||
| {%- elif cookiecutter.code_formatter == 'ruff' %} | ||
| ruff = "^0.12.2" |
There was a problem hiding this comment.
The linter group is empty when code_formatter is 'none'. However, the pre-commit configuration for this case includes isort and pyupgrade hooks (lines 36-44 in .pre-commit-config.yaml). For consistency, add an else clause to include these dependencies: isort = "^5.12.0" and pyupgrade = "^3.15.0".
| ruff = "^0.12.2" | |
| ruff = "^0.12.2" | |
| {%- else %} | |
| isort = "^5.12.0" | |
| pyupgrade = "^3.15.0" |
|
|
||
| [tool.isort]{% if cookiecutter.code_formatter == 'black' %} | ||
| profile = "black"{% else %} | ||
| py_version = 310 |
There was a problem hiding this comment.
The py_version setting should be a string, not an integer. Change py_version = 310 to py_version = "310" or use the more standard format py_version = "3.10".
| py_version = 310 | |
| py_version = "3.10" |
| {%- if cookiecutter.code_formatter == 'ruff' %} | ||
|
|
||
| [tool.ruff] | ||
| line-length = 100 | ||
| src = ["src", "tests"] | ||
| target-version = "py311" | ||
| exclude = ["__init__.py"] | ||
| extend-exclude = ["notebooks/*"] | ||
|
|
||
| [tool.ruff.lint] | ||
| select = [ | ||
| "E", # Pycodestyle errors | ||
| "F", # Pyflakes errors | ||
| "UP", # pyupgrade checks | ||
| "B", # Bugbear checks | ||
| "SIM",# Simplification checks | ||
| "I", # Import order checks (isort) | ||
| "N" # Naming convention checks | ||
| ] | ||
| test = ["pytest>=8.4.1", "pytest-cov>=6.2.1"] | ||
| task-tags = ["TODO", "FIXME", "NOTE"] | ||
|
|
||
| [tool.ruff.lint.isort] | ||
| known-first-party = ["{{ cookiecutter.module_name }}"] | ||
|
|
||
| [tool.ruff.lint.pycodestyle] | ||
| max-line-length = 100 | ||
|
|
||
| [tool.ruff.lint.flake8-quotes] | ||
| inline-quotes = "double" | ||
| multiline-quotes = "double" | ||
| docstring-quotes = "double" | ||
| {%- endif %} |
There was a problem hiding this comment.
This Ruff configuration block is duplicated. The same configuration already exists at lines 46-77 for the Poetry section. Having duplicate configuration blocks will cause issues in the generated pyproject.toml file. Remove this duplicate block to avoid configuration conflicts.
| {%- endif %} | ||
| "isort>=5.12.0" | ||
| {%- elif cookiecutter.code_formatter == 'ruff' %} | ||
| "ruff>=0.12.2" |
There was a problem hiding this comment.
The linter dependency group is empty when code_formatter is 'none'. However, the pre-commit configuration for this case includes isort and pyupgrade hooks (lines 36-44 in .pre-commit-config.yaml). For consistency, the linter group should include these dependencies: "isort>=5.12.0" and "pyupgrade>=3.15.0".
| "ruff>=0.12.2" | |
| "ruff>=0.12.2" | |
| {%- else %} | |
| "isort>=5.12.0", | |
| "pyupgrade>=3.15.0" |
| "ruff.lint.run": "onSave", | ||
| "ruff.format.args": ["--config=pyproject.toml"] |
There was a problem hiding this comment.
The --config=pyproject.toml argument is unnecessary. Ruff automatically discovers and uses pyproject.toml configuration from the project root. This explicit argument can be removed to simplify the configuration.
| "ruff.lint.run": "onSave", | |
| "ruff.format.args": ["--config=pyproject.toml"] | |
| "ruff.lint.run": "onSave" |
| "SIM",# Simplification checks | ||
| "I", # Import order checks (isort) |
There was a problem hiding this comment.
Missing space after comma in inline comments. For consistency with Python and TOML formatting conventions, add a space after the comma: "SIM", # Simplification checks" and "I", # Import order checks".
| "SIM",# Simplification checks | |
| "I", # Import order checks (isort) | |
| "SIM", # Simplification checks | |
| "I", # Import order checks (isort) |
| "UP", # pyupgrade checks | ||
| "B", # Bugbear checks | ||
| "SIM",# Simplification checks |
There was a problem hiding this comment.
Missing space after comma in inline comments. For consistency with Python and TOML formatting conventions, add a space after the comma: "SIM", # Simplification checks" and "I", # Import order checks".
| "UP", # pyupgrade checks | |
| "B", # Bugbear checks | |
| "SIM",# Simplification checks | |
| "UP", # pyupgrade checks | |
| "B", # Bugbear checks | |
| "SIM", # Simplification checks |
| "editor.defaultFormatter": "ms-python.python" | ||
| {% elif cookiecutter.code_formatter == 'ruff' %} // Use ruff as our linter and formatter | ||
| "[python]": { | ||
| "editor.formatOnSave": true, | ||
| "editor.codeActionsOnSave": { | ||
| "source.fixAll": "explicit", | ||
| "source.organizeImports": "explicit" | ||
| }, | ||
| "editor.defaultFormatter": "charliermarsh.ruff" | ||
| }, | ||
| "ruff.lint.run": "onSave", | ||
| "ruff.format.args": ["--config=pyproject.toml"] |
There was a problem hiding this comment.
Missing comma after the last property in each conditional block. When the template is rendered, the JSON object needs a comma after the last property before the closing brace of the root object. Add a comma at the end of line 17 for the black formatter case and at the end of line 28 for the ruff formatter case to create valid JSON.
No description provided.