Skip to content

Commit 8942ca2

Browse files
author
Ricardo
authored
Merge pull request #6 from cuenca-mx/update
Update library
2 parents 7b7b75c + 6f98be3 commit 8942ca2

9 files changed

Lines changed: 93 additions & 45 deletions

File tree

Makefile

Lines changed: 41 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,57 @@ SHELL := bash
22
PATH := ./venv/bin:${PATH}
33
PYTHON=python3.7
44
PROJECT=cep
5-
isort = isort -rc -ac $(PROJECT) tests setup.py
5+
isort = isort $(PROJECT) tests setup.py
66
black = black -S -l 79 --target-version py37 $(PROJECT) tests setup.py
77

8-
all: test
8+
.PHONY: all
9+
all: testt
910

1011
venv:
11-
$(PYTHON) -m venv --prompt $(PROJECT) venv
12-
pip install -qU pip
12+
$(PYTHON) -m venv --prompt $(PROJECT) venv
13+
pip install -qU pip
1314

14-
install-test:
15-
pip install -q .[test]
15+
.PHONY: install
16+
install:
17+
pip install -qU -r requirements.txt
1618

19+
.PHONY: install-test
20+
install-test: install
21+
pip install -qU -r requirements-test.txt
22+
23+
.PHONY: test
1724
test: clean install-test lint
18-
python setup.py test
25+
pytest
1926

27+
.PHONY: format
2028
format:
21-
$(isort)
22-
$(black)
29+
$(isort)
30+
$(black)
2331

32+
.PHONY: lint
2433
lint:
25-
$(isort) --check-only
26-
$(black) --check
27-
flake8 $(PROJECT) tests setup.py
34+
$(isort) --check-only
35+
$(black) --check
36+
flake8 $(PROJECT) tests setup.py
37+
mypy $(PROJECT) tests
2838

39+
.PHONY: clean
2940
clean:
30-
find . -name '*.pyc' -exec rm -f {} +
31-
find . -name '*.pyo' -exec rm -f {} +
32-
find . -name '*~' -exec rm -f {} +
33-
rm -rf build dist $(PROJECT).egg-info
34-
35-
release: clean
36-
python setup.py sdist bdist_wheel
37-
twine upload dist/*
38-
39-
40-
.PHONY: all install-test release test clean-pyc
41+
rm -rf `find . -name __pycache__`
42+
rm -f `find . -type f -name '*.py[co]' `
43+
rm -f `find . -type f -name '*~' `
44+
rm -f `find . -type f -name '.*~' `
45+
rm -rf .cache
46+
rm -rf .pytest_cache
47+
rm -rf .mypy_cache
48+
rm -rf htmlcov
49+
rm -rf *.egg-info
50+
rm -f .coverage
51+
rm -f .coverage.*
52+
rm -rf build
53+
rm -rf dist
54+
55+
.PHONY: release
56+
release: test clean
57+
python setup.py sdist bdist_wheel
58+
twine upload dist/*

cep/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
__all__ = ['Cuenta', 'Client', 'Transferencia']
1+
__all__ = ['__version__', 'Cuenta', 'Client', 'Transferencia']
22

33
from .client import Client
44
from .cuenta import Cuenta
55
from .transferencia import Transferencia
6+
from .version import __version__

cep/py.typed

Whitespace-only changes.

cep/transferencia.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def validar(
5656
receptor=receptor,
5757
sello=resp.get('sello'),
5858
)
59-
transferencia.__client = client
59+
setattr(transferencia, '__client', client)
6060
return transferencia
6161

6262
def descargar(self, formato: str = 'PDF') -> bytes:
@@ -97,9 +97,8 @@ def _validar(
9797
monto=monto,
9898
)
9999
resp = client.post('/valida.do', request_body)
100-
if b'no encontrada' in resp:
101-
client = None # No pudó validar
102-
return client
100+
# None si no pudó validar
101+
return client if b'no encontrada' not in resp else None
103102

104103
@staticmethod
105104
def _descargar(client: Client, formato: str = 'PDF') -> bytes:

cep/version.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = '0.1.4'

requirements-test.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
pytest==5.4.3
2+
pytest-vcr==1.0.2
3+
pytest-cov==2.10.0
4+
black==19.10b0
5+
flake8==3.8.3
6+
isort[pipfile]==4.3.21
7+
mypy==0.790

requirements.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
requests==2.24.0
2+
clabe==1.2.0
3+
lxml==4.5.1
4+
dataclasses>=0.6;python_version<"3.7"

setup.cfg

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,28 @@ test=pytest
33

44
[tool:pytest]
55
addopts = -p no:warnings -v --cov-report term-missing --cov=cep
6+
7+
[flake8]
8+
inline-quotes = '
9+
multiline-quotes = """
10+
11+
[isort]
12+
multi_line_output=3
13+
include_trailing_comma=True
14+
force_grid_wrap=0
15+
combine_as_imports=True
16+
17+
[mypy-lxml]
18+
ignore_missing_imports = true
19+
20+
[mypy-clabe]
21+
ignore_missing_imports = true
22+
23+
[mypy-pytest]
24+
ignore_missing_imports = true
25+
26+
[coverage:report]
27+
precision = 2
28+
exclude_lines =
29+
pragma: no cover
30+
if TYPE_CHECKING:

setup.py

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import setuptools
1+
from importlib.machinery import SourceFileLoader
2+
3+
from setuptools import find_packages, setup
4+
5+
version = SourceFileLoader('version', 'cep/version.py').load_module()
26

37
install_requirements = [
48
'requests==2.24.0',
@@ -7,36 +11,25 @@
711
'dataclasses>=0.6;python_version<"3.7"',
812
]
913

10-
test_requires = (
11-
[
12-
'pytest==5.4.3',
13-
'pytest-vcr==1.0.2',
14-
'pytest-cov==2.10.0',
15-
'black==19.10b0',
16-
'flake8==3.8.3',
17-
'isort[pipfile]==4.3.21',
18-
],
19-
)
2014

2115
with open('README.md', 'r') as f:
2216
long_description = f.read()
2317

2418

25-
setuptools.setup(
19+
setup(
2620
name='cepmex',
27-
version='0.1.3',
21+
version=version.__version__,
2822
author='Cuenca',
2923
author_email='dev@cuenca.com',
3024
description='CEP client library',
3125
long_description=long_description,
3226
long_description_content_type='text/markdown',
3327
url='https://github.com/cuenca-mx/cep-python',
34-
packages=setuptools.find_packages(),
28+
packages=find_packages(),
29+
include_package_data=True,
30+
package_data=dict(cep=['py.typed']),
3531
python_requires='>=3.7',
3632
install_requires=install_requirements,
37-
setup_requires=['pytest-runner'],
38-
tests_require=test_requires,
39-
extras_require=dict(test=test_requires),
4033
classifiers=[
4134
'Programming Language :: Python :: 3.7',
4235
'License :: OSI Approved :: MIT License',

0 commit comments

Comments
 (0)