Skip to content

feat: enhance .editorconfig and add .gitattributes#330

Closed
davebulaval wants to merge 80 commits intosuperlinear-ai:mainfrom
Baseline-quebec:feat/editorconfig-gitattributes
Closed

feat: enhance .editorconfig and add .gitattributes#330
davebulaval wants to merge 80 commits intosuperlinear-ai:mainfrom
Baseline-quebec:feat/editorconfig-gitattributes

Conversation

@davebulaval
Copy link

Summary

Supersedes #328 — fixes the issues from the community PR:

Changes:

  • Enhance existing .editorconfig: add max_line_length = 99, web file types, .sh/.bat line endings
  • Add .gitattributes for consistent line ending normalization across OS

Closes #327

Test plan

  • Run cookiecutter . and verify .editorconfig and .gitattributes are generated in the output project
  • Verify .editorconfig has max_line_length = 99 for Python files
  • Verify .gitattributes normalizes line endings correctly

🤖 Generated with Claude Code

GameSetAndMatch and others added 28 commits June 3, 2024 15:55
fix(cli.py): fixed ruff format
* Update .pre-commit-config.yaml to avoid problems with docs and PDF

* Create adr_template.md

* Fix ruff in cli.py
* fix(Dockerfile): Small Dockerfile optimizations

* fix(README): Update README for starter project

* fix: changed logging to loguru

* refactor: Update README, upgrade poetry version in Dockerfile

* fix(Dockerfile): fixed poetry install command

* fix typo in README

---------

Co-authored-by: Jean-Samuel Leboeuf <jean-samuel.leboeuf@baseline.quebec>
* fix: resolve 5 P0 bugs that break template generation

- Fix post_gen_project.py test file names (test_api.py, test_cli.py)
  and add cleanup for BDD feature files
- Remove dead parameters (continuous_integration, teamwork_uri) from
  cookiecutter.json and hook
- Fix docker-compose target: api → app to match Dockerfile stage name
- Wrap poe api task, Dockerfile CMD, and docker-compose api service
  in FastAPI conditional
- Fix coverage.xml config: directory → output in pyproject.toml
- Remove broken base-app Dockerfile stage (--only app with no app group)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* feat: add pytest-bdd structure with feature files and step definitions

- Rename *_test.py → test_*.py (standard pytest convention)
- Add tests/features/ with Gherkin scenarios (import, api, cli)
- Add BDD step definitions using scenarios() and parsers.cfparse
- Add tests/conftest.py with shared fixtures and conditional
  FastAPI TestClient
- Add pytest-bdd and httpx to test dependencies
- Configure bdd_features_base_dir in pytest ini options

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* chore: update dependencies, CI, and meta-repo configuration

- Update pre-commit hooks: pygrep-hooks v1.11, pre-commit-hooks v5.0
- Extend trailing-whitespace and end-of-file-fixer to all file types
- Remove obsolete ANN101/ANN102 ruff rules (removed upstream)
- Clean simple mode ruff ignores (G010, S101, S307 not in selected set)
- Update CI: checkout v5, Node 22, devcontainers@latest, add
  workflow_dispatch
- Add git safe.directory config and Poetry 2.2.1 in Dockerfile
- Make PYTHONFAULTHANDLER/PYTHONUNBUFFERED unconditional in Dockerfile
- Add TODO for teamwork.yml SHA pinning
- Fix README: replace radix-ai refs, remove GPG feature, fix French
  text, document with_conventional_commits param
- Update root devcontainer Python 3.10 → 3.12

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* feat: sprint 2 — cookiecutter enhancements (14 items)

Add pre-generation validation, pydantic-settings, enriched stubs,
Sentry integration, API middleware, debug configs, and DevOps tooling.

Phase 1 — Infrastructure:
- Add hooks/pre_gen_project.py (validate project_name, python_version >= 3.10, warn sentry without FastAPI)
- Add .editorconfig (UTF-8, LF, Python 4sp, YAML/JSON 2sp, Makefile tabs)
- Add CHANGELOG.md (Keep a Changelog format, compatible with cz bump)

Phase 2 — pydantic-settings:
- Add settings.py with BaseSettings (env_file=".env", extra="ignore")
- Replace python-decouple with pydantic-settings >= 2.2.0 in pyproject.toml
- Update .env_sample with all documented variables (General, FastAPI, Sentry sections)

Phase 3 — Enriched stubs:
- Add models.py (ItemCreate, Item, HealthResponse with Field validators)
- Add services.py (ItemService with create/get/list_all in-memory pattern)
- Rewrite api.py: health endpoint, items CRUD, Annotated + Depends DI, response_model
- Rewrite cli.py: @app.callback() with --verbose, info (Rich Table), greet (Annotated arg)
- Update post_gen_project.py to remove models.py/services.py when FastAPI disabled
- Rewrite test files and feature files (3 scenarios each for API and CLI)

Phase 4 — API enhancements:
- Add StarletteHTTPException handler (structured JSON + log warning)
- Add generic Exception handler (500 JSON + log exception)
- Add RequestLoggingMiddleware (method, path, status, duration_ms via loguru)

Phase 5 — Sentry SDK:
- Add with_sentry to cookiecutter.json (default "0")
- Add sentry-sdk conditional dep in pyproject.toml
- Add sentry fields in settings.py (dsn, environment, traces_sample_rate)
- Add sentry_sdk.init() in api.py lifespan (conditional on non-empty dsn)
- Document with_sentry in root README.md

Phase 6 — Test infra + cleanup:
- Add pytest-asyncio >= 0.23.0 conditional to FastAPI
- Add asyncio_mode = "auto" and asyncio_default_fixture_loop_scope = "function"
- Split addopts into clean strict/simple if/else blocks
- Split .pre-commit-config.yaml ruff args into clean if/else blocks
- Add PytestUnraisableExceptionWarning to filterwarnings
- Enable ruff preview mode, add max-public-methods = 30

Phase 7 — DevOps:
- Add .vscode/launch.json (FastAPI uvicorn, pytest, Current File configs)
- Update .gitignore: .vscode/* + !.vscode/launch.json
- Add multi-Python CI matrix (+ 3.13 if not already selected)
- Add Docker HEALTHCHECK using stdlib urllib (no curl in slim images)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(ci): fix pygrep-hooks tag, pre-commit stages, and CI scaffold

- pygrep-hooks v1.11.0 does not exist, downgrade to v1.10.0
- default_stages: commit → pre-commit (deprecated name)
- Root CI: use matrix python-version in scaffold, drop radixai image override

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: remove JSON comment from launch.json (fails check-json hook)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: add missing trailing newlines to template files

Fixes end-of-file-fixer pre-commit hook failures on
devcontainer.json, dependabot.yml, and pull_request_template.md.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: remove extra trailing newline in .pre-commit-config.yaml template

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: use --pytest-test-first for name-tests-test hook

The --pytest flag expects *_test.py pattern, but our tests use
test_*.py. The --pytest-test-first flag matches the correct pattern.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: remove trailing whitespace in dependabot.yml and PR template

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: resolve ruff preview mode errors (RUF029, DOC201, D107)

- Remove async from exception handlers (sync is valid for FastAPI)
- Add noqa RUF029 to lifespan (required async by @asynccontextmanager)
- Add __init__ docstring to ItemService
- Ignore DOC201/DOC501 in strict config (too verbose for templates)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: resolve FAST001, PLR6301, FBT002 ruff errors

- Remove redundant response_model when return type is annotated (FAST001)
- Add noqa PLR6301 for dispatch method (required by BaseHTTPMiddleware)
- Add noqa FBT002 for verbose bool (required by Typer)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: resolve remaining ruff auto-fix issues

- AsyncGenerator[None, None] → AsyncGenerator[None] (UP043)
- Remove stale noqa PLC0415 (rule renamed in latest ruff)
- Fix import order in test_cli.py (I001)
- Remove deprecated PD901 from ignore list

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: resolve mypy errors in api.py and test_import.py

- Replace call_next: ... with RequestResponseEndpoint type
- Fix test_import.py return type: type → ModuleType

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: correct bdd scenario paths (double features/ prefix)

bdd_features_base_dir is already set to tests/features/ so scenario
paths should be relative to that, not include features/ again.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: avoid typer.Context in CLI to fix typeguard conflict

typeguard (strict mode) rejects typer's Context during testing.
Use module-level _verbose flag instead of ctx.obj pattern.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* chore: remove Teamwork integration

Remove teamwork.yml workflow, Teamwork link from PR template,
and Teamwork references from README. Teamwork is no longer used.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* feat: address PR review comments

- Rename .env_sample to .env.example
- Update reference in CONTRIBUTING.md
- Add CHANGELOG.md for the cookiecutter repo

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: davebulaval <david.beauchemin@ift.ulaval.ca>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: davebulaval <david.beauchemin@ift.ulaval.ca>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
* feat: sprint 3 — template improvements (10 items)

- Add license parameter (MIT, Apache-2.0, Proprietary) with LICENSE template
- Add github_org parameter for repository URL construction
- Add with_pytest_bdd parameter (default off) with conditional BDD/plain tests
- Bump all dependency versions (ruff, fastapi, pytest, mypy, sentry-sdk, etc.)
- Update pre-commit-hooks v5→v6, Poetry 2.2.1→2.3.2
- Add Docker layer caching + Buildx to CI workflow
- Simplify Dockerfile from 4 stages to 3 (merge base+poetry)
- Replace CLI greet command with config + health commands
- Add poe update task for cruft template sync
- Add first ADR (0001-record-architecture-decisions) and Confluence link
- Add dependabot.yml at repo root
- Add 46 template generation tests (tests/test_cookiecutter.py)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* feat: sprint 4 — CI/CD, codespell, mkdocs, lint fixes

Template improvements:
- Replace pdoc with MkDocs Material for documentation
- Add codespell linter to pre-commit and pyproject.toml
- Add PR title check workflow (conventional commits)
- Bump actions/checkout to v6
- Fix ruff lint errors (FURB171, PLC0415, PLR2004, PLR6201)

Root CI/CD:
- Add fast CI workflow (pytest, Python 3.12/3.13)
- Add PR title check workflow
- Modernize integration test (matrix full/minimal, cruft check, pip cache)
- Enrich pre-commit (pre-commit-hooks, actionlint, ruff)
- Add CODEOWNERS (@davebulaval, @Dpothier)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: resolve ruff and codespell lint errors in generated template

- cli.py: iterate dict keys directly instead of .items() (B007, PERF102)
- CONTRIBUTING.md: fix typos (developpement, environnement, developpers)
- pyproject.toml: fix "formater" → "formatter", add Jupyter to codespell ignore

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: resolve remaining ruff and coverage errors in generated template

- cli.py: remove unused `import sys`, remove stale noqa comments (S310, BLE001)
- test_import.py: add settings test to ensure coverage > 50% in minimal config

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: correct Jinja whitespace in cli.py imports

Fix blank line between stdlib imports causing ruff I001 (unsorted imports)
and ruff format failure.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: davebulaval <david.beauchemin@ift.ulaval.ca>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
- Rewrite root README with CI badges, project structure, and developer guide
- Conditionalize generated README sections (API, CLI, Docker) with Jinja
- Fix CONTRIBUTING.md typos and conditionalize FastAPI section
- Add CLAUDE.md template for AI-assisted development in generated projects
- Add pull_request_template.md for the cookiecutter repo itself
- Add 11 unit tests for CLAUDE.md and conditional README (71 total)
- Update CHANGELOG.md with full sprint history

Co-authored-by: davebulaval <david.beauchemin@ift.ulaval.ca>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
…ls (#24)

- Ajouter le hook Yelp/detect-secrets dans .pre-commit-config.yaml
- Ajouter detect-secrets>=1.5.0 dans les dépendances de test
- Générer le fichier .secrets.baseline initial (vide)

Co-authored-by: davebulaval <david.beauchemin@ift.ulaval.ca>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
- Ajouter description de detect-secrets dans la section pre-commit du CONTRIBUTING.md
- Ajouter l'entrée detect-secrets dans le CHANGELOG (Unreleased)

Co-authored-by: davebulaval <david.beauchemin@ift.ulaval.ca>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
- Add max_line_length = 99 to .editorconfig (Baseline convention)
- Add web file types (css, html, js, jsx, ts, tsx) to indent rules
- Add .sh (LF) and .bat (CRLF) line ending rules
- Add .gitattributes for consistent line ending normalization

Closes superlinear-ai#327

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@davebulaval
Copy link
Author

Created by mistake against upstream. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feature request]Add .editorconfig and .gitattributes for workspace consistency

4 participants