Skip to content

Commit fdb6954

Browse files
Merge branch 'main' into create-pull-request/patch
2 parents 92e7114 + 1a3f00a commit fdb6954

6 files changed

Lines changed: 62 additions & 19 deletions

File tree

.pre-commit-config.yaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,6 @@ repos:
5454
- id: markdownlint-cli2
5555
args: ["--fix"]
5656
priority: 0
57-
- repo: https://github.com/rbubley/mirrors-prettier
58-
rev: v3.8.1
59-
hooks:
60-
- id: prettier
61-
types_or: [markdown]
62-
priority: 0
6357
- repo: https://github.com/codespell-project/codespell
6458
rev: v2.4.1
6559
hooks:
@@ -158,6 +152,12 @@ repos:
158152
always_run: true
159153
pass_filenames: false
160154
priority: 1
155+
- repo: https://github.com/rbubley/mirrors-prettier
156+
rev: v3.8.1
157+
hooks:
158+
- id: prettier
159+
types_or: [markdown]
160+
priority: 2
161161
- repo: local
162162
hooks:
163163
- id: deptry
@@ -166,22 +166,22 @@ repos:
166166
language: system
167167
always_run: true
168168
pass_filenames: false
169-
priority: 2
169+
priority: 3
170170
- id: import-linter
171171
name: import-linter
172172
entry: uv run --frozen --offline lint-imports
173173
language: system
174174
always_run: true
175175
pass_filenames: false
176-
priority: 2
176+
priority: 3
177177
- id: ty
178178
name: ty
179179
entry: uv run --frozen --offline ty check
180180
language: system
181181
types_or: [python, pyi]
182182
always_run: true
183183
require_serial: true
184-
priority: 2
184+
priority: 3
185185
default_stages:
186186
- pre-commit
187187
- pre-push

CHANGELOG.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,52 @@
11
# Changelog
22

3+
## 0.21.0
4+
5+
### 🚀 New Features
6+
7+
- There is now support for the [Poetry](https://python-poetry.org/) backend in usethis. Access it via the `--backend=poetry` option for applicable commands.
8+
- Tools which add formatters (`usethis format`, `usethis tool pyproject-fmt`, and `usethis tool ruff`) will now automatically apply the formatter to the project when added.
9+
- There is now a `usethis tool tach` command to add the [Tach architecture tool](https://github.com/tach-org/tach) to the project.
10+
- `usethis tool` commands now support a `--no-hook` flag to opt out of modifying git hook configuration (e.g. in `.pre-commit-config.yaml`) when managing the tool.
11+
- `usethis show` commands now support an `--output-file` option to write the output to a file instead of printing it to the console.
12+
- There is now a `usethis show license` command to show the license of the current project.
13+
- There is now a `usethis badge bitbucket` command to add a badge for Bitbucket usage to the README.
14+
- `usethis tool pytest` and `usethis test` will now automatically add an example test file. This helps ensure that `pytest` will run out-of-the-box without emitting a non-zero error code.
15+
16+
### 🐞 Bug Fixes
17+
18+
- In some cases, when usethis modified TOML files, comments would be stripped from multi-line lists. This has been fixed.
19+
- Out-of-schema entries in `.pre-commit-config.yaml` files will no longer result in errors when being handled by usethis. This is especially useful for prek users, since prek extends `.pre-commit-config.yaml` with support for additional configuration options which are not found in the standard pre-commit schema.
20+
21+
### 🦾 Robustness
22+
23+
- Hard-wrapping is now disabled for CLI outputs.
24+
- The `usethis tool requirements.txt` command now uses a more standard URI-based pre-commit hook for exporting (using the `astral-sh/uv-pre-commit` repo) instead of a local system hook.
25+
- Default code coverage configuration now excludes the pattern `msg = ["']` associated with writing error messages outside the error class (see the [`EM101`](https://docs.astral.sh/ruff/rules/raw-string-in-exception/) Ruff rule).
26+
- The heuristic for detecting uv usage will now check whether uv is declared as a dependency (including as a dev dependency) in `pyproject.toml` when the file exists, in addition to the previous heuristics. This should help reduce false positives for projects which use other tools but have `pyproject.toml` files with no uv configuration.
27+
- There is improved handling of pre-commit configuration validation for when the hook ID is null.
28+
29+
### 📚 Documentation
30+
31+
- The `usethis show sonarqube` command is now documented explicitly in the CLI reference section of the documentation site.
32+
- The concept of backends is [now expounded on the documentation site](https://usethis.readthedocs.io/en/latest/about/backends/).
33+
- All modules now have module docstrings.
34+
- The project description and keywords have been updated to reflect the current state of the project. The license Trove classifier has been removed since Trove classifiers for licenses are no longer recommended.
35+
- The FAQ page has been re-structured.
36+
- The pipeweld utility now has more comprehensive docstrings.
37+
- The `FileManager` and `files_manager` objects now have more detailed docstrings.
38+
39+
### 📦 Packaging
40+
41+
- The `identify` package is a new dependency to provide support for the `usethis show license` command.
42+
43+
### 🔧 Internal Changes
44+
45+
- There is improved type compliance, especially for the implementation of the file management system.
46+
- Ruff configuration now resides in `ruff.toml` for development.
47+
- There is now a `PreCommitConfig.from_system_hook` method to simplify the specification of pre-commit hook configuration for the various tools.
48+
- Agent configuration and bespoke prek hooks continue to be developed.
49+
350
## 0.20.0
451

552
### 💥 Changes

hooks/fix-doc-sync.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
from __future__ import annotations
1414

15-
import os
1615
import re
1716
import sys
1817
from pathlib import Path
@@ -70,7 +69,7 @@ def _detect_codeblock_fence(text: str) -> str:
7069

7170
def _build_replacement(actual_content: str, expected: str) -> str:
7271
"""Build the replacement content for a sync block, preserving code fences."""
73-
nl = os.linesep
72+
nl = "\n"
7473
fence = _detect_codeblock_fence(actual_content)
7574
if fence:
7675
return f"{nl}{fence}{nl}{expected}{nl}```{nl}{nl}"
@@ -138,7 +137,7 @@ def _fix_file(path: Path) -> bool:
138137
)
139138
continue
140139

141-
with open(source, encoding="utf-8", newline="") as f:
140+
with open(source, encoding="utf-8") as f:
142141
expected = f.read().strip()
143142
actual_content = "".join(content_lines)
144143
replacement = _build_replacement(actual_content, expected)

hooks/fix-readme.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from __future__ import annotations
1111

1212
import argparse
13-
import os
1413
import sys
1514
from pathlib import Path
1615

@@ -48,10 +47,8 @@ def main() -> int:
4847
)
4948
env.globals["include_doc"] = _include_doc # pyright: ignore[reportArgumentType]
5049

51-
template = env.get_template(str(template_path))
50+
template = env.get_template(template_path.as_posix())
5251
content = template.render()
53-
if os.linesep != "\n":
54-
content = content.replace("\n", os.linesep)
5552

5653
try:
5754
with open(output_file, encoding="utf-8", newline="") as f:

tests/usethis/_file/toml/test_toml_io_.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ def relative_path(self) -> Path:
664664
manager.extend_list(keys=["key"], values=["new_value"])
665665

666666
def test_preserves_comments(self, tmp_path: Path) -> None:
667-
# https://github.com/usethis-python/usethis-python/issues/884
667+
# https://github.com/usethis-python/usethis-python/issues/1171
668668
# Arrange
669669
class MyTOMLFileManager(TOMLFileManager):
670670
@property
@@ -808,7 +808,7 @@ def relative_path(self) -> Path:
808808
assert manager._content == {"key": "value"}
809809

810810
def test_preserves_comments(self, tmp_path: Path) -> None:
811-
# https://github.com/usethis-python/usethis-python/issues/884
811+
# https://github.com/usethis-python/usethis-python/issues/1171
812812
# Arrange
813813
class MyTOMLFileManager(TOMLFileManager):
814814
@property

tests/usethis/_tool/impl/base/test_ruff.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ def test_group_replaces_specific(self, tmp_path: Path):
332332
assert result
333333

334334
def test_preserves_comments(self, tmp_path: Path):
335-
# https://github.com/usethis-python/usethis-python/issues/884
335+
# https://github.com/usethis-python/usethis-python/issues/1171
336336
# Arrange
337337
(tmp_path / "ruff.toml").write_text(
338338
"""\

0 commit comments

Comments
 (0)