diff --git a/Makefile b/Makefile index af615e9..f9e5447 100644 --- a/Makefile +++ b/Makefile @@ -2,39 +2,57 @@ SHELL := bash PATH := ./venv/bin:${PATH} PYTHON=python3.7 PROJECT=cep -isort = isort -rc -ac $(PROJECT) tests setup.py +isort = isort $(PROJECT) tests setup.py black = black -S -l 79 --target-version py37 $(PROJECT) tests setup.py -all: test +.PHONY: all +all: testt venv: - $(PYTHON) -m venv --prompt $(PROJECT) venv - pip install -qU pip + $(PYTHON) -m venv --prompt $(PROJECT) venv + pip install -qU pip -install-test: - pip install -q .[test] +.PHONY: install +install: + pip install -qU -r requirements.txt +.PHONY: install-test +install-test: install + pip install -qU -r requirements-test.txt + +.PHONY: test test: clean install-test lint - python setup.py test + pytest +.PHONY: format format: - $(isort) - $(black) + $(isort) + $(black) +.PHONY: lint lint: - $(isort) --check-only - $(black) --check - flake8 $(PROJECT) tests setup.py + $(isort) --check-only + $(black) --check + flake8 $(PROJECT) tests setup.py + mypy $(PROJECT) tests +.PHONY: clean clean: - find . -name '*.pyc' -exec rm -f {} + - find . -name '*.pyo' -exec rm -f {} + - find . -name '*~' -exec rm -f {} + - rm -rf build dist $(PROJECT).egg-info - -release: clean - python setup.py sdist bdist_wheel - twine upload dist/* - - -.PHONY: all install-test release test clean-pyc + rm -rf `find . -name __pycache__` + rm -f `find . -type f -name '*.py[co]' ` + rm -f `find . -type f -name '*~' ` + rm -f `find . -type f -name '.*~' ` + rm -rf .cache + rm -rf .pytest_cache + rm -rf .mypy_cache + rm -rf htmlcov + rm -rf *.egg-info + rm -f .coverage + rm -f .coverage.* + rm -rf build + rm -rf dist + +.PHONY: release +release: test clean + python setup.py sdist bdist_wheel + twine upload dist/* diff --git a/cep/__init__.py b/cep/__init__.py index a9bb1bb..0075cfe 100644 --- a/cep/__init__.py +++ b/cep/__init__.py @@ -1,5 +1,6 @@ -__all__ = ['Cuenta', 'Client', 'Transferencia'] +__all__ = ['__version__', 'Cuenta', 'Client', 'Transferencia'] from .client import Client from .cuenta import Cuenta from .transferencia import Transferencia +from .version import __version__ diff --git a/cep/py.typed b/cep/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/cep/transferencia.py b/cep/transferencia.py index a08897b..cd3f469 100644 --- a/cep/transferencia.py +++ b/cep/transferencia.py @@ -56,7 +56,7 @@ def validar( receptor=receptor, sello=resp.get('sello'), ) - transferencia.__client = client + setattr(transferencia, '__client', client) return transferencia def descargar(self, formato: str = 'PDF') -> bytes: @@ -97,9 +97,8 @@ def _validar( monto=monto, ) resp = client.post('/valida.do', request_body) - if b'no encontrada' in resp: - client = None # No pudó validar - return client + # None si no pudó validar + return client if b'no encontrada' not in resp else None @staticmethod def _descargar(client: Client, formato: str = 'PDF') -> bytes: diff --git a/cep/version.py b/cep/version.py new file mode 100644 index 0000000..7525d19 --- /dev/null +++ b/cep/version.py @@ -0,0 +1 @@ +__version__ = '0.1.4' diff --git a/requirements-test.txt b/requirements-test.txt new file mode 100644 index 0000000..756c2c3 --- /dev/null +++ b/requirements-test.txt @@ -0,0 +1,7 @@ +pytest==5.4.3 +pytest-vcr==1.0.2 +pytest-cov==2.10.0 +black==19.10b0 +flake8==3.8.3 +isort[pipfile]==4.3.21 +mypy==0.790 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..f973110 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +requests==2.24.0 +clabe==1.2.0 +lxml==4.5.1 +dataclasses>=0.6;python_version<"3.7" diff --git a/setup.cfg b/setup.cfg index 441024b..4718c66 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,3 +3,28 @@ test=pytest [tool:pytest] addopts = -p no:warnings -v --cov-report term-missing --cov=cep + +[flake8] +inline-quotes = ' +multiline-quotes = """ + +[isort] +multi_line_output=3 +include_trailing_comma=True +force_grid_wrap=0 +combine_as_imports=True + +[mypy-lxml] +ignore_missing_imports = true + +[mypy-clabe] +ignore_missing_imports = true + +[mypy-pytest] +ignore_missing_imports = true + +[coverage:report] +precision = 2 +exclude_lines = + pragma: no cover + if TYPE_CHECKING: diff --git a/setup.py b/setup.py index 8b37b2f..fbed658 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,8 @@ -import setuptools +from importlib.machinery import SourceFileLoader + +from setuptools import find_packages, setup + +version = SourceFileLoader('version', 'cep/version.py').load_module() install_requirements = [ 'requests==2.24.0', @@ -7,36 +11,25 @@ 'dataclasses>=0.6;python_version<"3.7"', ] -test_requires = ( - [ - 'pytest==5.4.3', - 'pytest-vcr==1.0.2', - 'pytest-cov==2.10.0', - 'black==19.10b0', - 'flake8==3.8.3', - 'isort[pipfile]==4.3.21', - ], -) with open('README.md', 'r') as f: long_description = f.read() -setuptools.setup( +setup( name='cepmex', - version='0.1.3', + version=version.__version__, author='Cuenca', author_email='dev@cuenca.com', description='CEP client library', long_description=long_description, long_description_content_type='text/markdown', url='https://github.com/cuenca-mx/cep-python', - packages=setuptools.find_packages(), + packages=find_packages(), + include_package_data=True, + package_data=dict(cep=['py.typed']), python_requires='>=3.7', install_requires=install_requirements, - setup_requires=['pytest-runner'], - tests_require=test_requires, - extras_require=dict(test=test_requires), classifiers=[ 'Programming Language :: Python :: 3.7', 'License :: OSI Approved :: MIT License',