Skip to content

Commit

Permalink
Initial implementation (#1)
Browse files Browse the repository at this point in the history
* UK modulus checker implementation

* Review

* Review

* Review

* Review
  • Loading branch information
Yaroslav authored Apr 27, 2022
1 parent 4ebd3d6 commit 47275d9
Show file tree
Hide file tree
Showing 21 changed files with 1,948 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @anna-money/banking-backend
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: pip
directory: "/"
schedule:
interval: daily
time: "00:00"
open-pull-requests-limit: 10
66 changes: 66 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: CI

on:
push:
branches:
- master
tags: [ 'v*' ]
pull_request:
branches:
- master


jobs:
test:
name: Test
runs-on: ubuntu-latest
timeout-minutes: 15

strategy:
matrix:
python-version: ["3.10"]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
make deps
- name: Lint
run: |
make lint
- name: Tests
run: |
make test
deploy:
name: Deploy
runs-on: ubuntu-latest
needs: test
# Run only on pushing a tag
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Python 3.10
uses: actions/setup-python@v2
with:
python-version: "3.10"
- name: Install dependencies
run:
python -m pip install -U pip wheel twine
- name: Make dists
run:
python setup.py sdist bdist_wheel
- name: Check dists
run:
twine check dist/*
- name: PyPI upload
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
twine upload dist/*
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# ANNA
.idea

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
45 changes: 45 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
.EXPORT_ALL_VARIABLES:
DIRECTORY = uk_modulus_check

all: deps lint test

deps:
@python3 -m pip install --upgrade pip && pip3 install -r requirements-dev.txt

lint: black isort flake8 mypy

mypy:
mypy $(DIRECTORY)
mypy tests

flake8:
flake8 $(DIRECTORY)
flake8 tests
flake8 setup.py

black:
ifeq ($(MODE), ci)
black $(DIRECTORY) --check
black tests --check
black setup.py --check
else
black $(DIRECTORY)
black tests
black setup.py
endif

isort:
ifeq ($(MODE), ci)
isort $(DIRECTORY) -c
isort tests -c
else
isort $(DIRECTORY)
isort tests
isort setup.py
endif

test:
@python3 -m pytest -vv --rootdir tests .

pyenv:
echo uk-modulus-check > .python-version && pyenv install -s 3.10.3 && pyenv virtualenv -f 3.10.3 uk-modulus-check
9 changes: 9 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
pytest==7.1.1
pytest-runner==6.0.0
isort==5.10.1
flake8==4.0.1
mypy==0.942
black==22.3.0
setuptools==62.1.0
wheel==0.37.1
twine==4.0.0
31 changes: 31 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[flake8]
exclude = ,.git,__pycache__,old,build,dist,env/ # noqa
max-line-length = 120
ignore = C901,C812,E203,E225
extend-ignore = W503
no-accept-encodings = True
enable-extensions=G

[mypy]
python_version = 3.10
ignore_missing_imports = True
disallow_incomplete_defs = True
no_implicit_optional = True
disallow_untyped_calls = True
warn_redundant_casts = True
warn_unused_ignores = True
disallow_untyped_defs = True
check_untyped_defs = True

[isort]
combine_as_imports = true
default_section = THIRDPARTY
include_trailing_comma = true
use_parentheses = true
line_length = 120
multi_line_output = 3


[tool:pytest]
norecursedirs = .git .venv
python_files = tests.py test_*.py *_tests.py
42 changes: 42 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import re
from pathlib import Path

from setuptools import setup


def read(*parts):
return Path(__file__).resolve().parent.joinpath(*parts).read_text().strip()


def read_version():
regexp = re.compile(r"^__version__\W*=\W*\"([\d.abrc]+)\"")
for line in read("uk_modulus_check", "__init__.py").splitlines():
match = regexp.match(line)
if match is not None:
return match.group(1)
else:
raise RuntimeError("Cannot find version in uk_modulus_check/__init__.py")


with open("README.md", "r") as fh:
long_description = fh.read()


setup(
name="uk-modulus-check",
version=read_version(),
description="A thing to check UK bank sort code and IBAN",
long_description=long_description,
long_description_content_type="text/markdown",
platforms=["macOS", "POSIX", "Windows"],
author="ANNA",
python_requires=">=3.10",
project_urls={},
author_email="[email protected]",
license="MIT",
packages=["uk_modulus_check"],
package_dir={"uk_modulus_check": "./uk_modulus_check"},
package_data={"uk_modulus_check": ["py.typed"]},
include_package_data=True,
exclude_package_data={"data": ["data/*.txt"]},
)
Empty file added tests/__init__.py
Empty file.
Empty file added tests/data/__init__.py
Empty file.
21 changes: 21 additions & 0 deletions tests/data/subs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
938173 938017
938289 938068
938297 938076
938600 938611
938602 938343
938604 938603
938608 938408
938609 938424
938613 938017
938616 938068
938618 938657
938620 938343
938622 938130
938628 938181
938643 938246
938647 938611
938648 938246
938649 938394
938651 938335
938653 938424
938654 938621
Loading

0 comments on commit 47275d9

Please sign in to comment.