Skip to content

Commit f51b128

Browse files
committed
update project
1 parent fe95a80 commit f51b128

8 files changed

Lines changed: 918 additions & 621 deletions

File tree

CLAUDE.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Claude Code Development Guidelines
2+
3+
## Project Overview
4+
create-python-cmd - Cross platform productivity commands written in Python
5+
6+
## Development Environment
7+
- Python 3.8+ required
8+
- Use virtual environment for development
9+
- Run commands from project root
10+
11+
## Linting and Type Checking
12+
- Linting: `ruff check .`
13+
- Formatting: `black .`
14+
- Type checking: `pyright`
15+
16+
Always run these before committing changes.
17+
18+
## Testing Requirements
19+
- Framework: pytest
20+
- Run tests: `pytest`
21+
- Parallel execution: `pytest -n auto`
22+
- With coverage: `pytest --cov=src/create_python_cmd`
23+
24+
**IMPORTANT: NO MOCKS IN TESTS**
25+
- Write integration tests that test actual functionality
26+
- Use temporary directories for file operations
27+
- Test real command execution
28+
29+
## Code Standards
30+
1. **Exception Handling**
31+
- Always handle KeyboardInterrupt first
32+
- Log errors before handling
33+
- Use specific exception types
34+
35+
2. **Return Values**
36+
- Use dataclasses instead of tuples
37+
- Type all function returns
38+
39+
3. **File Structure**
40+
- All code in src/create_python_cmd/
41+
- Tests in tests/ with test_ prefix
42+
- Make test files executable standalone
43+
44+
## Example Test Structure
45+
46+
```python
47+
import pytest
48+
import tempfile
49+
import os
50+
from pathlib import Path
51+
52+
@pytest.mark.unit
53+
def test_real_functionality():
54+
"""Test actual functionality without mocks."""
55+
with tempfile.TemporaryDirectory() as tmpdir:
56+
# Perform real operations
57+
result = actual_function(tmpdir)
58+
assert result == expected
59+
60+
if __name__ == "__main__":
61+
pytest.main([__file__, "-v"])
62+
```

README.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
# create-python-cmd
22

3-
[![Linting](https://github.com/zackees/createpythonapp/actions/workflows/lint.yml/badge.svg)](https://github.com/zackees/createpythonapp/actions/workflows/lint.yml)
4-
5-
[![MacOS_Tests](https://github.com/zackees/createpythonapp/actions/workflows/push_macos.yml/badge.svg)](https://github.com/zackees/createpythonapp/actions/workflows/push_macos.yml)
6-
[![Ubuntu_Tests](https://github.com/zackees/createpythonapp/actions/workflows/push_ubuntu.yml/badge.svg)](https://github.com/zackees/createpythonapp/actions/workflows/push_ubuntu.yml)
7-
[![Win_Tests](https://github.com/zackees/createpythonapp/actions/workflows/push_win.yml/badge.svg)](https://github.com/zackees/createpythonapp/actions/workflows/push_win.yml)
8-
93

104
This is a command for creating a skeleton project for python commands. It uses
115
uv to boot strap the project and install an environment. Helpful utilities for
@@ -36,8 +30,7 @@ The following tools will be installed
3630
The following linters are used
3731
* `ruff`
3832
* `black`
39-
* `isort`
40-
* `mypy`
33+
* `pyright`
4134

4235

4336
# Uploading your project to PYPI

UPDATE.md

Lines changed: 287 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,287 @@
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+
[![Linting](https://github.com/zackees/createpythonapp/actions/workflows/lint.yml/badge.svg)](https://github.com/zackees/createpythonapp/actions/workflows/lint.yml)
272+
[![MacOS_Tests](https://github.com/zackees/createpythonapp/actions/workflows/push_macos.yml/badge.svg)](https://github.com/zackees/createpythonapp/actions/workflows/push_macos.yml)
273+
[![Ubuntu_Tests](https://github.com/zackees/createpythonapp/actions/workflows/push_ubuntu.yml/badge.svg)](https://github.com/zackees/createpythonapp/actions/workflows/push_ubuntu.yml)
274+
[![Win_Tests](https://github.com/zackees/createpythonapp/actions/workflows/push_win.yml/badge.svg)](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

Comments
 (0)