Skip to content

Commit a0af98c

Browse files
authored
Fix stdout trailing newline + upgrade to Pydantic v2 (#8)
* fix: remove extra newline when writing to stdout * feat: upgrade to pydantic v2 * chore: bump version to 0.4.0
1 parent b0a38ea commit a0af98c

File tree

10 files changed

+415
-340
lines changed

10 files changed

+415
-340
lines changed

.github/workflows/tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ jobs:
1313
runs-on: ubuntu-latest
1414
strategy:
1515
matrix:
16-
python-version: ['3.7', '3.8', '3.9', '3.10']
16+
python-version: ['3.8', '3.9', '3.10', '3.11']
1717
steps:
18-
- uses: actions/checkout@v2
18+
- uses: actions/checkout@v3
1919
- name: Set up Python
20-
uses: actions/setup-python@v2
20+
uses: actions/setup-python@v4
2121
with:
2222
python-version: ${{ matrix.python-version }}
2323
- name: Install dependencies

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,21 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88

9+
## 0.4.0 - 2023-07-14
10+
11+
### Changed
12+
13+
- Upgraded to Pydantic v2.
14+
15+
### Removed
16+
17+
- Dropped Python 3.7 support.
18+
19+
### Fixed
20+
21+
- Use a single trailing newline when writing to stdout.
22+
23+
924
## 0.3.3 - 2022-08-10
1025

1126
### Fixed

ocdc/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.3.3"
1+
__version__ = "0.4.0"

ocdc/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def format(args: argparse.Namespace) -> None:
6969
result = api.format(orig)
7070

7171
if is_stdin:
72-
print(result)
72+
print(result, end="")
7373
elif result != orig:
7474
if args.check:
7575
sys.exit(f"ERROR: {path} would be reformatted")

poetry.lock

Lines changed: 375 additions & 314 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "ocdc"
3-
version = "0.3.3"
3+
version = "0.4.0"
44
description = 'A changelog formatter for "people", neat freaks, and sloppy typists.'
55
authors = ["Matteo De Wint <[email protected]>"]
66
packages = [{ include = "ocdc" }]
@@ -13,18 +13,18 @@ keywords = ["changelog", "markdown", "formatter"]
1313
ocdc = "ocdc.__main__:main"
1414

1515
[tool.poetry.dependencies]
16-
packaging = "^21.3"
17-
pydantic = "^1.9.1"
18-
python = "^3.7"
16+
packaging = "^23.1"
17+
pydantic = "^2.0.2"
18+
python = "^3.8"
1919

2020
[tool.poetry.dev-dependencies]
21-
black = "^22.6.0"
21+
black = "^23.7.0"
2222
bump2version = "^1.0.1"
23-
coverage = "^6.4.2"
24-
flake8 = "^5.0.0"
25-
isort = "^5.10.1"
26-
mypy = "^0.971"
27-
pytest = "^7.1.2"
23+
coverage = "^7.2.7"
24+
flake8 = "^5.0.4"
25+
isort = "^5.12.0"
26+
mypy = "^1.4.1"
27+
pytest = "^7.4.0"
2828

2929
[build-system]
3030
requires = ["poetry-core>=1.0.0"]

setup.cfg

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[bumpversion]
2-
current_version = 0.3.3
2+
current_version = 0.4.0
33
commit = True
4+
message = chore: bump version to {new_version}
45

56
[flake8]
67
max-line-length = 88
@@ -24,9 +25,7 @@ no_implicit_optional = True
2425
warn_redundant_casts = True
2526
warn_unused_ignores = True
2627
warn_unreachable = True
27-
28-
[mypy-pytest.*]
29-
ignore_missing_imports = True
28+
plugins = pydantic.mypy
3029

3130
[tool:pytest]
3231
addopts = --tb=short

tests/unit/test_parser.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ def test_parse(text_path, dump_expected_output):
1717
text = text_path.read_text()
1818

1919
actual_ast = parse(text)
20-
a = actual_ast.json(indent=2, exclude_defaults=True)
20+
a = actual_ast.model_dump_json(indent=2, exclude_defaults=True)
2121

2222
ast_path = Path(str(text_path).split(".", 1)[0] + ".ast.json")
2323
if dump_expected_output:
2424
dump_expected_output(ast_path, a + "\n")
2525

26-
expected_ast = ast.Changelog.parse_file(ast_path)
27-
b = expected_ast.json(indent=2, exclude_defaults=True)
26+
expected_ast = ast.Changelog.model_validate_json(ast_path.read_text())
27+
b = expected_ast.model_dump_json(indent=2, exclude_defaults=True)
2828

2929
assert a == b
3030

tests/unit/test_renderer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
@pytest.mark.parametrize("text_path", text_paths, ids=[p.name for p in text_paths])
1313
def test_render_markdown(text_path, dump_expected_output):
1414
ast_path = Path(str(text_path).split(".", 1)[0] + ".ast.json")
15-
changelog = ast.Changelog.parse_file(ast_path)
15+
changelog = ast.Changelog.model_validate_json(ast_path.read_text())
1616

1717
actual_text = render_markdown(changelog)
1818

tox.ini

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[tox]
2-
envlist = py{37,38,39,310}, lint
2+
envlist = py{38,39,310,311}, lint
33
isolated_build = True
44

55
[gh-actions]
66
python =
7-
3.7: py37
87
3.8: py38
98
3.9: py39
10-
3.10: py310, lint
9+
3.10: py310
10+
3.11: py311, lint
1111

1212
[testenv]
1313
allowlist_externals =

0 commit comments

Comments
 (0)