Skip to content

Commit

Permalink
Merge pull request #43 from honzajavorek/honzajavorek/facelift
Browse files Browse the repository at this point in the history
Facelift
  • Loading branch information
honzajavorek authored Dec 28, 2024
2 parents a960443 + 8644568 commit 2c7224c
Show file tree
Hide file tree
Showing 15 changed files with 506 additions and 194 deletions.
21 changes: 0 additions & 21 deletions .editorconfig

This file was deleted.

7 changes: 7 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ jobs:
- name: Build
run: uv build

- name: Smoke Test
run: |
uv venv .smoketest
uv pip install --python=.smoketest/bin/python ./dist/fiobank-*.tar.gz
.smoketest/bin/python -c 'from fiobank import FioBank'
rm -r .smoketest
- name: Publish package
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') && github.repository == 'honzajavorek/fiobank'
run: uv publish --trusted-publishing always
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- uses: astral-sh/setup-uv@v5

- name: Install
run: uv pip install --system -e .[tests]
run: uv sync

- name: Test
run: pytest
run: uv run pytest
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ venv/
ENV/
env.bak/
venv.bak/
.smoketest/

# Spyder project settings
.spyderproject
Expand All @@ -153,3 +154,6 @@ dmypy.json

# Cython debug symbols
cython_debug/

# pytest
.pytest_cache
32 changes: 0 additions & 32 deletions CHANGELOG.md

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2024, Honza Javorek <[email protected]>
Copyright (c) 2025, Honza Javorek <[email protected]>

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

Expand Down
43 changes: 19 additions & 24 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
fiobank
=======

|PyPI version| |Build Status| |Test Coverage|

`Fio Bank API <http://www.fio.cz/bank-services/internetbanking-api>`__
`Fio Bank API <http://www.fio.cz/bank-services/internetbanking-api>`_
in Python.

Installation
------------

.. code:: sh
From PyPI::

pip install fiobank

$ pip install fiobank
In case you have an adventurous mind, give a try to the source::

pip install git+https://github.com/honzajavorek/fiobank.git#egg=fiobank

Usage
-----
Expand Down Expand Up @@ -76,35 +78,28 @@ Listing the latest transactions:
Conflict Error
--------------

`Fio API documentation <http://www.fio.cz/docs/cz/API_Bankovnictvi.pdf>`__
(Section 8.2) states that a single token should be used only once per
`Fio API documentation <http://www.fio.cz/docs/cz/API_Bankovnictvi.pdf>`_
(Section 8.3) states that a single token should be used only once per
30s. Otherwise, an HTTP 409 Conflict will be returned and
``fiobank.ThrottlingError`` will be raised.

Contributing
------------
Development
-----------

.. code:: shell
Install using `uv <https://docs.astral.sh/uv/>`_::

$ pip install -e .[tests]
$ pytest
git clone [email protected]:honzajavorek/fiobank.git
cd fiobank
uv sync

Changelog
---------
Then run tests::

See `GitHub Releases <https://github.com/honzajavorek/fiobank/releases>`_.
uv run pytest

License: ISC
------------

© 2024 Honza Javorek [email protected]
© 2025 Honza Javorek <[email protected]>

This work is licensed under the `ISC
license <https://en.wikipedia.org/wiki/ISC_license>`__.

.. |PyPI version| image:: https://badge.fury.io/py/fiobank.svg
:target: https://badge.fury.io/py/fiobank
.. |Build Status| image:: https://github.com/honzajavorek/fiobank/actions/workflows/test.yml/badge.svg
:target: https://github.com/honzajavorek/fiobank/actions/workflows/test.yml
.. |Test Coverage| image:: https://coveralls.io/repos/github/honzajavorek/fiobank/badge.svg?branch=master
:target: https://coveralls.io/github/honzajavorek/fiobank?branch=master
license <https://en.wikipedia.org/wiki/ISC_license>`_.
12 changes: 10 additions & 2 deletions fiobank.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
from decimal import Decimal
import re
from datetime import datetime, date
import warnings
from datetime import date, datetime
from decimal import Decimal

import requests


__all__ = ("FioBank", "ThrottlingError")


def coerce_amount(value):
if isinstance(value, int):
return Decimal(value)
if isinstance(value, float):
return Decimal(str(value))
raise ValueError(value)


def coerce_date(value):
if isinstance(value, datetime):
return value.date()
Expand Down
46 changes: 46 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[project]
name = "fiobank"
version = "4.0.0"
description = "Fio Bank API in Python (unofficial)"
readme = "README.rst"
authors = [{name = "Honza Javorek", email = "[email protected]"}]
license = {text = "ICS"}
requires-python = "<4.0,>=3.9"
dependencies = [
"requests<3.0.0,>=2.28.2",
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: ISC License (ISCL)",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Internet",
]

[project.urls]
repository = "https://github.com/honzajavorek/fiobank"

[dependency-groups]
dev = [
"pytest<8.0.0,>=7.2.1",
"responses<1.0.0,>=0.22.0",
"mock<6.0.0,>=5.0.1",
"ruff<1.0.0,>=0.8.4",
"pytest-ruff<1.0.0,>=0.4.1",
]

[tool.pytest.ini_options]
pythonpath = ["."]
testpaths = "tests"
norecursedirs = "env venv .git"
addopts = "--ff --ruff --ruff-format"
filterwarnings = ["ignore:Using float for money can cause inaccuracies:DeprecationWarning"]

[tool.ruff.lint]
extend-select = ["I"]

[tool.ruff.lint.isort]
combine-as-imports = true
lines-after-imports = 2
13 changes: 0 additions & 13 deletions setup.cfg

This file was deleted.

58 changes: 0 additions & 58 deletions setup.py

This file was deleted.

18 changes: 11 additions & 7 deletions tests/test_coerce_date.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
from datetime import date, datetime

import pytest

from fiobank import coerce_date


@pytest.mark.parametrize('test_input', [
date(2016, 8, 3),
datetime(2016, 8, 3, 21, 3, 42),
'2016-08-03T21:03:42',
])
@pytest.mark.parametrize(
"test_input",
[
date(2016, 8, 3),
datetime(2016, 8, 3, 21, 3, 42),
"2016-08-03T21:03:42",
],
)
def test_coerce_date(test_input):
assert coerce_date(test_input) == date(2016, 8, 3)


@pytest.mark.parametrize('test_input', [42, True])
@pytest.mark.parametrize("test_input", [42, True])
def test_coerce_date_invalid_type(test_input):
with pytest.raises(TypeError):
coerce_date(test_input)


@pytest.mark.parametrize('test_input', ['21:03:42', '[email protected]'])
@pytest.mark.parametrize("test_input", ["21:03:42", "[email protected]"])
def test_coerce_date_invalid_value(test_input):
with pytest.raises(ValueError):
coerce_date(test_input)
Loading

0 comments on commit 2c7224c

Please sign in to comment.