Skip to content

Commit

Permalink
Fix stdout trailing newline + upgrade to Pydantic v2 (#8)
Browse files Browse the repository at this point in the history
* fix: remove extra newline when writing to stdout

* feat: upgrade to pydantic v2

* chore: bump version to 0.4.0
  • Loading branch information
mdwint authored Jul 13, 2023
1 parent b0a38ea commit a0af98c
Show file tree
Hide file tree
Showing 10 changed files with 415 additions and 340 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10']
python-version: ['3.8', '3.9', '3.10', '3.11']
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand Down
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,21 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## 0.4.0 - 2023-07-14

### Changed

- Upgraded to Pydantic v2.

### Removed

- Dropped Python 3.7 support.

### Fixed

- Use a single trailing newline when writing to stdout.


## 0.3.3 - 2022-08-10

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion ocdc/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.3.3"
__version__ = "0.4.0"
2 changes: 1 addition & 1 deletion ocdc/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def format(args: argparse.Namespace) -> None:
result = api.format(orig)

if is_stdin:
print(result)
print(result, end="")
elif result != orig:
if args.check:
sys.exit(f"ERROR: {path} would be reformatted")
Expand Down
689 changes: 375 additions & 314 deletions poetry.lock

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "ocdc"
version = "0.3.3"
version = "0.4.0"
description = 'A changelog formatter for "people", neat freaks, and sloppy typists.'
authors = ["Matteo De Wint <[email protected]>"]
packages = [{ include = "ocdc" }]
Expand All @@ -13,18 +13,18 @@ keywords = ["changelog", "markdown", "formatter"]
ocdc = "ocdc.__main__:main"

[tool.poetry.dependencies]
packaging = "^21.3"
pydantic = "^1.9.1"
python = "^3.7"
packaging = "^23.1"
pydantic = "^2.0.2"
python = "^3.8"

[tool.poetry.dev-dependencies]
black = "^22.6.0"
black = "^23.7.0"
bump2version = "^1.0.1"
coverage = "^6.4.2"
flake8 = "^5.0.0"
isort = "^5.10.1"
mypy = "^0.971"
pytest = "^7.1.2"
coverage = "^7.2.7"
flake8 = "^5.0.4"
isort = "^5.12.0"
mypy = "^1.4.1"
pytest = "^7.4.0"

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand Down
7 changes: 3 additions & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[bumpversion]
current_version = 0.3.3
current_version = 0.4.0
commit = True
message = chore: bump version to {new_version}

[flake8]
max-line-length = 88
Expand All @@ -24,9 +25,7 @@ no_implicit_optional = True
warn_redundant_casts = True
warn_unused_ignores = True
warn_unreachable = True

[mypy-pytest.*]
ignore_missing_imports = True
plugins = pydantic.mypy

[tool:pytest]
addopts = --tb=short
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ def test_parse(text_path, dump_expected_output):
text = text_path.read_text()

actual_ast = parse(text)
a = actual_ast.json(indent=2, exclude_defaults=True)
a = actual_ast.model_dump_json(indent=2, exclude_defaults=True)

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

expected_ast = ast.Changelog.parse_file(ast_path)
b = expected_ast.json(indent=2, exclude_defaults=True)
expected_ast = ast.Changelog.model_validate_json(ast_path.read_text())
b = expected_ast.model_dump_json(indent=2, exclude_defaults=True)

assert a == b

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@pytest.mark.parametrize("text_path", text_paths, ids=[p.name for p in text_paths])
def test_render_markdown(text_path, dump_expected_output):
ast_path = Path(str(text_path).split(".", 1)[0] + ".ast.json")
changelog = ast.Changelog.parse_file(ast_path)
changelog = ast.Changelog.model_validate_json(ast_path.read_text())

actual_text = render_markdown(changelog)

Expand Down
6 changes: 3 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[tox]
envlist = py{37,38,39,310}, lint
envlist = py{38,39,310,311}, lint
isolated_build = True

[gh-actions]
python =
3.7: py37
3.8: py38
3.9: py39
3.10: py310, lint
3.10: py310
3.11: py311, lint

[testenv]
allowlist_externals =
Expand Down

0 comments on commit a0af98c

Please sign in to comment.