Skip to content

Commit

Permalink
Merge pull request #298 from fyntex/release/v0.17.1
Browse files Browse the repository at this point in the history
Release v0.17.1
  • Loading branch information
ycouce-cdd committed Feb 16, 2022
2 parents 7a5830e + 8facd74 commit 3b747a1
Show file tree
Hide file tree
Showing 75 changed files with 1,595 additions and 1,062 deletions.
12 changes: 12 additions & 0 deletions .black.cfg.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Black Configuration
#
# Black is a Python source code formatter.
#
# - Web site: https://github.com/psf/black/
# - Documentation: https://black.readthedocs.io/

[tool.black]
include = '\.pyi?$'
line-length = 100
skip-string-normalization = true
target-version = ['py38', 'py39']
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.17.0
current_version = 0.17.1
commit = True
tag = True

Expand Down
6 changes: 4 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ jobs:
. venv/bin/activate
pip install --upgrade pip
pip install --upgrade setuptools wheel
pip install -r requirements/test.txt
pip install -r requirements.txt
pip install -r requirements-dev.txt
- run:
name: Check Dependencies
Expand Down Expand Up @@ -93,7 +94,8 @@ jobs:
. venv/bin/activate
pip install --upgrade pip
pip install --upgrade setuptools wheel
pip install -r requirements/release.txt
pip install -r requirements.txt
pip install -r requirements-dev.txt
- run:
name: Check Dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ updates:
interval: daily
time: "08:30"
timezone: America/Santiago
open-pull-requests-limit: 3
open-pull-requests-limit: 20
labels:
- dependencies
24 changes: 24 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Isort Configuration
#
# Isort is a Python import sorter.
#
# - Web site: https://github.com/PyCQA/isort/
# - Configuration options: https://pycqa.github.io/isort/docs/configuration/options/

[settings]
combine_as_imports=false
ensure_newline_before_comments=true
extra_standard_library=
force_grid_wrap=0
force_single_line=false
include_trailing_comma=true
known_first_party=
known_local_folder=
known_third_party=
line_length=100
lines_after_imports=2
multi_line_output=3
no_lines_before=LOCALFOLDER
sections=FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
skip_gitignore=true
use_parentheses=true
10 changes: 10 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
History
-------

0.17.1 (2022-02-16)
+++++++++++++++++++++++

* (PR #269, 2022-02-03) chore: Add tool to automatically sort Python imports
* (PR #274, 2022-02-08) chore: Increase Dependabot's open pull request limit for `pip`
* (PR #273, 2022-02-08) requirements: Update 'Flake8'
* (PR #292, 2022-02-08) chore: Increase Django REST Framework required maximum version to 3.13.x
* (PR #294, 2022-02-09) chore: Simplify organization of Python dependency manifests
* (PR #272, 2022-02-10) Add 'Black' Python code formatter

0.17.0 (2022-01-27)
+++++++++++++++++++++++

Expand Down
11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
SHELL = /usr/bin/env bash

# Black
BLACK = black --config .black.cfg.toml

.DEFAULT_GOAL := help
.PHONY: help
.PHONY: clean clean-build clean-pyc clean-test
.PHONY: lint test test-all test-coverage test-coverage-report-console test-coverage-report-html
.PHONY: lint lint-fix test test-all test-coverage test-coverage-report-console test-coverage-report-html
.PHONY: dist upload-release

help:
Expand Down Expand Up @@ -35,6 +38,12 @@ clean-test: ## remove test, lint and coverage artifacts
lint: ## run tools for code style analysis, static type check, etc
flake8 --config=setup.cfg cl_sii scripts tests
mypy --config-file setup.cfg cl_sii scripts
isort --check-only .
$(BLACK) --check .

lint-fix: ## Fix lint errors
$(BLACK) .
isort .

test: ## run tests quickly with the default Python
python setup.py test
Expand Down
3 changes: 2 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ Tests

Requirements::

pip install -r requirements/test.txt
pip install -r requirements.txt
pip install -r requirements-dev.txt

Run test suite for all supported Python versions and run tools for
code style analysis, static type check, etc::
Expand Down
2 changes: 1 addition & 1 deletion cl_sii/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
"""


__version__ = '0.17.0'
__version__ = '0.17.1'
12 changes: 8 additions & 4 deletions cl_sii/cte/f29/data_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@
Any,
ClassVar,
Iterator,
Mapping, MutableMapping,
Mapping,
MutableMapping,
Optional,
Set,
Type, Tuple,
Tuple,
Type,
Union,
)

from cl_sii.rut import Rut
from cl_sii.rcv.data_models import PeriodoTributario
from cl_sii.rut import Rut


logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -222,7 +224,9 @@ def __post_init__(self) -> None:
"%s(contribuyente_rut=%r, periodo_tributario=%r, folio=%r)"
" contains invalid or unknown SII Form 29 codes: %s.",
self.__class__.__name__,
self.contribuyente_rut, self.periodo_tributario, self.folio,
self.contribuyente_rut,
self.periodo_tributario,
self.folio,
', '.join(str(code) for code in sorted(unknown_codes)),
)

Expand Down
12 changes: 7 additions & 5 deletions cl_sii/cte/f29/parse_datos_obj.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@
import jsonschema

from cl_sii.libs.json_utils import JsonSchemaValidationError, read_json_schema
from cl_sii.rut import Rut
from cl_sii.rcv.data_models import PeriodoTributario

from cl_sii.rut import Rut
from .data_models import CteForm29


SiiCteF29DatosObjType = Mapping[str, Mapping[str, object]]
_CTE_F29_DATOS_OBJ_SCHEMA_PATH = (
Path(__file__).parent.parent.parent
/ 'data' / 'cte' / 'schemas-json' / 'f29_datos_obj.schema.json'
/ 'data'
/ 'cte'
/ 'schemas-json'
/ 'f29_datos_obj.schema.json'
)
CTE_F29_DATOS_OBJ_SCHEMA = read_json_schema(_CTE_F29_DATOS_OBJ_SCHEMA_PATH)

Expand Down Expand Up @@ -95,11 +97,11 @@ def _parse_sii_cte_f29_datos_obj_to_dict(
folio=obj_extra[7],
contribuyente_rut=obj_extra[3],
periodo_tributario=periodo_tributario,

#
tipo_declaracion=datos_obj_extras.get('CLASE'),
banco=datos_obj_extras.get('BANCO'),
medio_pago=datos_obj_extras.get('MEDIO_PAGO'),

#
extra=obj_extra,
)
return obj_dict
Expand Down
6 changes: 3 additions & 3 deletions cl_sii/dte/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"""DTE field 'Folio' type."""
DTE_FOLIO_FIELD_MIN_VALUE = 1
"""DTE field 'Folio' min value."""
DTE_FOLIO_FIELD_MAX_VALUE = 10 ** 10
DTE_FOLIO_FIELD_MAX_VALUE = 10**10
"""DTE field 'Folio' max value."""


Expand Down Expand Up @@ -59,9 +59,9 @@

DTE_MONTO_TOTAL_FIELD_TYPE = int
"""DTE field 'Monto Total' type."""
DTE_MONTO_TOTAL_FIELD_MIN_VALUE = -10 ** 18
DTE_MONTO_TOTAL_FIELD_MIN_VALUE = -(10**18)
"""DTE field 'Monto Total' min value."""
DTE_MONTO_TOTAL_FIELD_MAX_VALUE = 10 ** 18
DTE_MONTO_TOTAL_FIELD_MAX_VALUE = 10**18
"""DTE field 'Monto Total' max value."""


Expand Down
74 changes: 48 additions & 26 deletions cl_sii/dte/data_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
from cl_sii.base.constants import SII_OFFICIAL_TZ
from cl_sii.libs import tz_utils
from cl_sii.rut import Rut

from . import constants
from .constants import TipoDte

Expand All @@ -39,9 +38,7 @@ def validate_dte_folio(value: int) -> None:
:raises TypeError:
"""
# note: mypy gets confused and complains about "Unsupported operand types for >/<".
if (value < constants.DTE_FOLIO_FIELD_MIN_VALUE # type: ignore
or value > constants.DTE_FOLIO_FIELD_MAX_VALUE): # type: ignore
if value < constants.DTE_FOLIO_FIELD_MIN_VALUE or value > constants.DTE_FOLIO_FIELD_MAX_VALUE:
raise ValueError("Value is out of the valid range for 'folio'.")


Expand All @@ -53,9 +50,10 @@ def validate_dte_monto_total(value: int, tipo_dte: TipoDte) -> None:
:raises TypeError:
"""
# note: mypy gets confused and complains about "Unsupported operand types for >/<".
if (value < constants.DTE_MONTO_TOTAL_FIELD_MIN_VALUE # type: ignore
or value > constants.DTE_MONTO_TOTAL_FIELD_MAX_VALUE): # type: ignore
if (
value < constants.DTE_MONTO_TOTAL_FIELD_MIN_VALUE
or value > constants.DTE_MONTO_TOTAL_FIELD_MAX_VALUE
):
raise ValueError("Value is out of the valid range for 'monto_total'.")

if value < 0 and tipo_dte != TipoDte.LIQUIDACION_FACTURA_ELECTRONICA:
Expand Down Expand Up @@ -100,9 +98,13 @@ def validate_non_empty_bytes(value: bytes) -> None:

@pydantic.dataclasses.dataclass(
frozen=True,
config=type('Config', (), dict(
arbitrary_types_allowed=True,
))
config=type(
'Config',
(),
dict(
arbitrary_types_allowed=True,
),
),
)
class DteNaturalKey:

Expand Down Expand Up @@ -170,9 +172,13 @@ def validate_folio(cls, v: object) -> object:

@pydantic.dataclasses.dataclass(
frozen=True,
config=type('Config', (), dict(
arbitrary_types_allowed=True,
))
config=type(
'Config',
(),
dict(
arbitrary_types_allowed=True,
),
),
)
class DteDataL0(DteNaturalKey):

Expand Down Expand Up @@ -208,9 +214,13 @@ def natural_key(self) -> DteNaturalKey:

@pydantic.dataclasses.dataclass(
frozen=True,
config=type('Config', (), dict(
arbitrary_types_allowed=True,
))
config=type(
'Config',
(),
dict(
arbitrary_types_allowed=True,
),
),
)
class DteDataL1(DteDataL0):

Expand Down Expand Up @@ -273,7 +283,8 @@ def vendedor_rut(self) -> Rut:
result = self.receptor_rut
else:
raise ValueError(
"Concept \"vendedor\" does not apply for this 'tipo_dte'.", self.tipo_dte)
"Concept \"vendedor\" does not apply for this 'tipo_dte'.", self.tipo_dte
)

return result

Expand All @@ -291,7 +302,8 @@ def comprador_rut(self) -> Rut:
else:
raise ValueError(
"Concepts \"comprador\" and \"deudor\" do not apply for this 'tipo_dte'.",
self.tipo_dte)
self.tipo_dte,
)

return result

Expand Down Expand Up @@ -320,9 +332,13 @@ def validate_monto_total(cls, v: object, values: Mapping[str, object]) -> object

@pydantic.dataclasses.dataclass(
frozen=True,
config=type('Config', (), dict(
arbitrary_types_allowed=True,
))
config=type(
'Config',
(),
dict(
arbitrary_types_allowed=True,
),
),
)
class DteDataL2(DteDataL1):

Expand Down Expand Up @@ -408,7 +424,8 @@ def as_dte_data_l1(self) -> DteDataL1:
folio=self.folio,
fecha_emision_date=self.fecha_emision_date,
receptor_rut=self.receptor_rut,
monto_total=self.monto_total)
monto_total=self.monto_total,
)

###########################################################################
# Validators
Expand Down Expand Up @@ -447,9 +464,13 @@ def validate_non_empty_stripped_str(cls, v: object) -> object:

@pydantic.dataclasses.dataclass(
frozen=True,
config=type('Config', (), dict(
arbitrary_types_allowed=True,
))
config=type(
'Config',
(),
dict(
arbitrary_types_allowed=True,
),
),
)
class DteXmlData(DteDataL1):

Expand Down Expand Up @@ -535,7 +556,8 @@ def as_dte_data_l1(self) -> DteDataL1:
folio=self.folio,
fecha_emision_date=self.fecha_emision_date,
receptor_rut=self.receptor_rut,
monto_total=self.monto_total)
monto_total=self.monto_total,
)

def as_dte_data_l2(self) -> DteDataL2:
return DteDataL2(
Expand Down

0 comments on commit 3b747a1

Please sign in to comment.