Skip to content

Commit

Permalink
chore: Upgrade Pydantic to 2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
tkarabela committed Nov 17, 2023
1 parent 7a7f7af commit 5140384
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 17 deletions.
21 changes: 14 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ pip install okane

## Example

```shell
head my_banking_statement.xml
```
$ head my_banking_statement.xml

```xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:camt.053.001.02">
<BkToCstmrStmt>
Expand All @@ -31,28 +34,33 @@ $ head my_banking_statement.xml
<CreDtTm>2023-04-01T12:00:00.000+02:00</CreDtTm>
<MsgRcpt>
<Nm>John Doe</Nm>
```

$ ./okane.py my_banking_statement.xml
```shell
okane my_banking_statement.xml
```

```json
{
"statement_id": "XXX-STATEMENT-ID",
"created_time": "2023-04-01T12:00:00+02:00",
"from_time": "2023-03-01T00:00:00+01:00",
"to_time": "2023-03-31T00:00:00+02:00",
"account_iban": "XXX-IBAN",
"opening_balance": {
"amount": 1000.0,
"amount": "1000.00",
"currency": "CZK",
"date": "2023-03-31"
},
"closing_balance": {
"amount": 2000.0,
"amount": "2000.00",
"currency": "CZK",
"date": "2023-03-31"
},
"transactions": [
{
"ref": "XXX-REF-1",
"amount": 1500.0,
"amount": "1500.00",
"currency": "CZK",
"val_date": "2023-04-01",
"remote_info": "Incoming payment",
Expand All @@ -62,7 +70,7 @@ $ ./okane.py my_banking_statement.xml
},
{
"ref": "XXX-REF-2",
"amount": -500.0,
"amount": "-500.00",
"currency": "CZK",
"val_date": "2023-04-01",
"remote_info": "Outbound payment",
Expand All @@ -72,7 +80,6 @@ $ ./okane.py my_banking_statement.xml
}
]
}
```


Expand Down
2 changes: 1 addition & 1 deletion okane.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def main(args: list[str]) -> int:
input_file = args.input_file

statement = BankToCustomerStatement.from_file(input_file)
print(statement.json(indent=4, ensure_ascii=False))
print(statement.model_dump_json(indent=4))

return 0

Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ include = [
[tool.poetry.dependencies]
python = "^3.10"
lxml = "^4.9"
pydantic = "^1.10"
pydantic = "^2.5"

[tool.poetry.group.dev.dependencies]
mypy = "^1.1"
pytest = "^7.2"
pytest = "^7.4"
pytest-cov = "^4.0"
lxml-stubs = "^0.4"

Expand Down
14 changes: 7 additions & 7 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ def test_cli(capsys):
"to_time": "2023-03-31T23:59:59.999000+02:00",
"account_iban": "XXX-IBAN",
"opening_balance": {
"amount": 1000.0,
"amount": "1000.00",
"currency": "CZK",
"date": "2023-03-01"
},
"closing_balance": {
"amount": 2000.0,
"amount": "2000.00",
"currency": "CZK",
"date": "2023-03-31"
},
"transactions": [
{
"ref": "XXX-REF-1",
"amount": -100.0,
"amount": "-100.00",
"currency": "CZK",
"val_date": "2023-03-01",
"remote_info": "Nákup dne 27.2.2023, částka 100.00 CZK\n ",
Expand All @@ -37,7 +37,7 @@ def test_cli(capsys):
},
{
"ref": "XXX-REF-2",
"amount": -200.0,
"amount": "-200.00",
"currency": "CZK",
"val_date": "2023-03-02",
"remote_info": None,
Expand All @@ -47,7 +47,7 @@ def test_cli(capsys):
},
{
"ref": "XXX-REF-3",
"amount": 1000.0,
"amount": "1000.00",
"currency": "CZK",
"val_date": "2023-03-07",
"remote_info": None,
Expand All @@ -57,7 +57,7 @@ def test_cli(capsys):
},
{
"ref": "XXX-REF-4",
"amount": 400.0,
"amount": "400.00",
"currency": "CZK",
"val_date": "2023-03-08",
"remote_info": "description",
Expand All @@ -67,7 +67,7 @@ def test_cli(capsys):
},
{
"ref": "XXX-REF-5",
"amount": -100.0,
"amount": "-100.00",
"currency": "CZK",
"val_date": "2023-03-31",
"remote_info": "transaction description",
Expand Down

0 comments on commit 5140384

Please sign in to comment.