|
| 1 | +task - modernize create-python-cmd |
| 2 | + |
| 3 | +codeup is the premier fixup from the create-python-cmd template for repo creation |
| 4 | + |
| 5 | +https://github.com/zackees/codeup |
| 6 | + |
| 7 | +The improvements in the pyproject.toml, dropping flake8, pylint, mypy, and just using ruff, pyright is the way to go. |
| 8 | + |
| 9 | +These improvements need to be merged back to this repo (create-python-cmd) |
| 10 | + |
| 11 | + |
| 12 | +Important to note is the CLAUDE.md rules. Migrate these rules to ours. |
| 13 | + |
| 14 | + |
| 15 | +## Next step |
| 16 | + |
| 17 | +You need to update the unit tests. |
| 18 | + |
| 19 | +Remember - NO MOCKS! |
| 20 | + |
| 21 | +Audit the previous tests and see if they no longer make sense. If so delete them, you can be aggressive in this because now we have ai to remake the tests. |
| 22 | + |
| 23 | +what also needs to be fixed up is the readme.md badges for linting and testing. we can't use relative paths anymore. So just get rid of them. |
| 24 | + |
| 25 | + |
| 26 | +## Investigation Findings |
| 27 | + |
| 28 | +### Current State Analysis |
| 29 | +1. **Dependencies**: The current pyproject.toml has mixed tooling - it includes both ruff and mypy, while codeup has streamlined to just ruff and pyright for linting/type checking. |
| 30 | + |
| 31 | +2. **Testing Dependencies**: Currently lists pytest but missing key testing packages that codeup uses: |
| 32 | + - pytest-xdist (parallel test execution) |
| 33 | + - pytest-timeout (prevent hanging tests) |
| 34 | + - pytest-cov (coverage reporting) |
| 35 | + |
| 36 | +3. **Tool Configurations**: No ruff or pyright configurations present in pyproject.toml, while codeup has comprehensive settings for both. |
| 37 | + |
| 38 | +4. **CLAUDE.md Rules**: Codeup emphasizes: |
| 39 | + - UV for environment management |
| 40 | + - KeyboardInterrupt handling prioritization |
| 41 | + - Dataclass usage over tuples |
| 42 | + - Test file standalone execution capability |
| 43 | + - Comprehensive exception logging |
| 44 | + |
| 45 | +5. **README Badges**: Current badges point to old repository (zackees/createpythonapp) and need removal as suggested. |
| 46 | + |
| 47 | +### Modernization Action Items |
| 48 | +1. **Update pyproject.toml**: |
| 49 | + - Remove mypy, keep ruff and pyright only |
| 50 | + - Add missing test dependencies (pytest-xdist, pytest-timeout, pytest-cov) |
| 51 | + - Add [tool.ruff] and [tool.pyright] configuration sections from codeup |
| 52 | + - Update Python version requirement to >=3.8 |
| 53 | + |
| 54 | +2. **Create CLAUDE.md**: |
| 55 | + - Adapt codeup's CLAUDE.md for this project |
| 56 | + - Include linting commands: `ruff check .`, `pyright` |
| 57 | + - Specify test execution: `pytest` with no mocks policy |
| 58 | + - Add project-specific development guidelines |
| 59 | + |
| 60 | +3. **Test Refactoring**: |
| 61 | + - Audit test_cli.py and test_createapp.py for relevance |
| 62 | + - Remove mock-based tests per directive |
| 63 | + - Ensure tests can run standalone with `if __name__ == "__main__"` |
| 64 | + - Add test markers for organization |
| 65 | + |
| 66 | +4. **Documentation Cleanup**: |
| 67 | + - Remove all badges from README.md |
| 68 | + - Update any references to old tooling (flake8, pylint, mypy) |
| 69 | + |
| 70 | + |
| 71 | +## Code Snippets for Proposed Changes |
| 72 | + |
| 73 | +### 1. Updated pyproject.toml |
| 74 | + |
| 75 | +```toml |
| 76 | +[build-system] |
| 77 | +requires = ["setuptools", "setuptools-scm"] |
| 78 | +build-backend = "setuptools.build_meta" |
| 79 | + |
| 80 | +[project] |
| 81 | +name = "create-python-cmd" |
| 82 | +description = "Cross platform(ish) productivity commands written in python." |
| 83 | +requires-python = ">=3.8" |
| 84 | +readme = "README.md" |
| 85 | +keywords = ["create python cmd"] |
| 86 | +license = { text = "BSD 3-Clause License" } |
| 87 | +classifiers = ["Programming Language :: Python :: 3"] |
| 88 | +dependencies = [ |
| 89 | + "ruff", |
| 90 | + "pyright", |
| 91 | + "black", |
| 92 | + "pytest", |
| 93 | + "pytest-xdist", |
| 94 | + "pytest-timeout", |
| 95 | + "pytest-cov", |
| 96 | +] |
| 97 | +version = "2.0.1" |
| 98 | + |
| 99 | +[project.scripts] |
| 100 | +createpythoncmd = "create_python_cmd.cli:main" |
| 101 | +create-python-cmd = "create_python_cmd.cli:main" |
| 102 | + |
| 103 | +[tool.ruff] |
| 104 | +line-length = 88 |
| 105 | +target-version = "py38" |
| 106 | +select = [ |
| 107 | + "E", # pycodestyle errors |
| 108 | + "W", # pycodestyle warnings |
| 109 | + "F", # pyflakes |
| 110 | + "I", # isort |
| 111 | + "UP", # pyupgrade |
| 112 | +] |
| 113 | +ignore = [ |
| 114 | + "E501", # line too long (handled by black) |
| 115 | +] |
| 116 | + |
| 117 | +[tool.pyright] |
| 118 | +include = ["src", "tests"] |
| 119 | +pythonVersion = "3.8" |
| 120 | +typeCheckingMode = "basic" |
| 121 | +reportMissingImports = true |
| 122 | +``` |
| 123 | + |
| 124 | +### 2. CLAUDE.md Template |
| 125 | + |
| 126 | +```markdown |
| 127 | +# Claude Code Development Guidelines |
| 128 | + |
| 129 | +## Project Overview |
| 130 | +create-python-cmd - Cross platform productivity commands written in Python |
| 131 | + |
| 132 | +## Development Environment |
| 133 | +- Python 3.8+ required |
| 134 | +- Use virtual environment for development |
| 135 | +- Run commands from project root |
| 136 | + |
| 137 | +## Linting and Type Checking |
| 138 | +- Linting: `ruff check .` |
| 139 | +- Formatting: `black .` |
| 140 | +- Type checking: `pyright` |
| 141 | + |
| 142 | +Always run these before committing changes. |
| 143 | + |
| 144 | +## Testing Requirements |
| 145 | +- Framework: pytest |
| 146 | +- Run tests: `pytest` |
| 147 | +- Parallel execution: `pytest -n auto` |
| 148 | +- With coverage: `pytest --cov=src/create_python_cmd` |
| 149 | + |
| 150 | +**IMPORTANT: NO MOCKS IN TESTS** |
| 151 | +- Write integration tests that test actual functionality |
| 152 | +- Use temporary directories for file operations |
| 153 | +- Test real command execution |
| 154 | + |
| 155 | +## Code Standards |
| 156 | +1. **Exception Handling** |
| 157 | + - Always handle KeyboardInterrupt first |
| 158 | + - Log errors before handling |
| 159 | + - Use specific exception types |
| 160 | + |
| 161 | +2. **Return Values** |
| 162 | + - Use dataclasses instead of tuples |
| 163 | + - Type all function returns |
| 164 | + |
| 165 | +3. **File Structure** |
| 166 | + - All code in src/create_python_cmd/ |
| 167 | + - Tests in tests/ with test_ prefix |
| 168 | + - Make test files executable standalone |
| 169 | + |
| 170 | +## Example Test Structure |
| 171 | + |
| 172 | +```python |
| 173 | +import pytest |
| 174 | +import tempfile |
| 175 | +import os |
| 176 | +from pathlib import Path |
| 177 | + |
| 178 | +@pytest.mark.unit |
| 179 | +def test_real_functionality(): |
| 180 | + """Test actual functionality without mocks.""" |
| 181 | + with tempfile.TemporaryDirectory() as tmpdir: |
| 182 | + # Perform real operations |
| 183 | + result = actual_function(tmpdir) |
| 184 | + assert result == expected |
| 185 | + |
| 186 | +if __name__ == "__main__": |
| 187 | + pytest.main([__file__, "-v"]) |
| 188 | +``` |
| 189 | +``` |
| 190 | + |
| 191 | +### 3. Refactored Test Example (tests/test_cli.py) |
| 192 | + |
| 193 | +```python |
| 194 | +""" |
| 195 | +Test command line interface functionality. |
| 196 | +""" |
| 197 | +import pytest |
| 198 | +import subprocess |
| 199 | +import sys |
| 200 | +from pathlib import Path |
| 201 | + |
| 202 | +@pytest.mark.unit |
| 203 | +def test_cli_help(): |
| 204 | + """Test that CLI help works.""" |
| 205 | + result = subprocess.run( |
| 206 | + [sys.executable, "-m", "create_python_cmd", "--help"], |
| 207 | + capture_output=True, |
| 208 | + text=True |
| 209 | + ) |
| 210 | + assert result.returncode == 0 |
| 211 | + assert "create-python-cmd" in result.stdout.lower() or "usage" in result.stdout.lower() |
| 212 | + |
| 213 | +@pytest.mark.unit |
| 214 | +def test_cli_version(): |
| 215 | + """Test version display.""" |
| 216 | + result = subprocess.run( |
| 217 | + ["createpythoncmd", "--version"], |
| 218 | + capture_output=True, |
| 219 | + text=True |
| 220 | + ) |
| 221 | + assert result.returncode == 0 |
| 222 | + assert "2.0" in result.stdout |
| 223 | + |
| 224 | +if __name__ == "__main__": |
| 225 | + pytest.main([__file__, "-v"]) |
| 226 | +``` |
| 227 | + |
| 228 | +### 4. GitHub Actions Update (.github/workflows/test.yml) |
| 229 | + |
| 230 | +```yaml |
| 231 | +name: Tests |
| 232 | + |
| 233 | +on: [push, pull_request] |
| 234 | + |
| 235 | +jobs: |
| 236 | + test: |
| 237 | + runs-on: ${{ matrix.os }} |
| 238 | + strategy: |
| 239 | + matrix: |
| 240 | + os: [ubuntu-latest, windows-latest, macos-latest] |
| 241 | + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] |
| 242 | + |
| 243 | + steps: |
| 244 | + - uses: actions/checkout@v3 |
| 245 | + |
| 246 | + - name: Set up Python |
| 247 | + uses: actions/setup-python@v4 |
| 248 | + with: |
| 249 | + python-version: ${{ matrix.python-version }} |
| 250 | + |
| 251 | + - name: Install dependencies |
| 252 | + run: | |
| 253 | + python -m pip install --upgrade pip |
| 254 | + pip install -e ".[dev]" |
| 255 | +
|
| 256 | + - name: Lint with ruff |
| 257 | + run: ruff check . |
| 258 | + |
| 259 | + - name: Type check with pyright |
| 260 | + run: pyright |
| 261 | + |
| 262 | + - name: Run tests |
| 263 | + run: pytest -v --cov=src/create_python_cmd |
| 264 | + |
| 265 | +``` |
| 266 | + |
| 267 | +### 5. Remove Badges from README.md |
| 268 | + |
| 269 | +In README.md, remove these lines: |
| 270 | +```markdown |
| 271 | +[](https://github.com/zackees/createpythonapp/actions/workflows/lint.yml) |
| 272 | +[](https://github.com/zackees/createpythonapp/actions/workflows/push_macos.yml) |
| 273 | +[](https://github.com/zackees/createpythonapp/actions/workflows/push_ubuntu.yml) |
| 274 | +[](https://github.com/zackees/createpythonapp/actions/workflows/push_win.yml) |
| 275 | +``` |
| 276 | + |
| 277 | +### 6. Updated requirements.testing.txt |
| 278 | + |
| 279 | +``` |
| 280 | +pytest>=7.0.0 |
| 281 | +pytest-xdist>=3.0.0 |
| 282 | +pytest-timeout>=2.1.0 |
| 283 | +pytest-cov>=4.0.0 |
| 284 | +pyright>=1.1.0 |
| 285 | +ruff>=0.1.0 |
| 286 | +black>=23.0.0 |
| 287 | +``` |
0 commit comments