Skip to content

Commit

Permalink
Merge pull request #699 from cordada/deploy/v0.33.0
Browse files Browse the repository at this point in the history
Deploy release v0.33.0
  • Loading branch information
svillegas-cdd authored Sep 24, 2024
2 parents 03cda07 + c8d922b commit 27f1547
Show file tree
Hide file tree
Showing 17 changed files with 293 additions and 35 deletions.
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.32.0
current_version = 0.33.0
commit = True
tag = False
message = chore: Bump version from {current_version} to {new_version}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
uses: actions/checkout@v4.1.7

- name: Set Up Python ${{ matrix.python_version }}
uses: actions/setup-python@v5.1.1
uses: actions/setup-python@v5.2.0
with:
python-version: "${{ matrix.python_version }}"

Expand Down Expand Up @@ -78,7 +78,7 @@ jobs:
uses: actions/checkout@v4.1.7

- name: Set Up Python ${{ matrix.python_version }}
uses: actions/setup-python@v5.1.1
uses: actions/setup-python@v5.2.0
with:
python-version: "${{ matrix.python_version }}"

Expand Down Expand Up @@ -137,7 +137,7 @@ jobs:
- name: Store Artifacts
if: ${{ always() }}
uses: actions/upload-artifact@v4.3.6
uses: actions/upload-artifact@v4.4.0
with:
name: test_reports_${{ matrix.python_version }}
path: test-reports/
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:

- name: Set Up Python
id: set_up_python
uses: actions/setup-python@v5.1.1
uses: actions/setup-python@v5.2.0
with:
python-version: "3.10.9"

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:

- name: Set Up Python
id: set_up_python
uses: actions/setup-python@v5.1.1
uses: actions/setup-python@v5.2.0
with:
python-version: "3.10.9"

Expand Down Expand Up @@ -68,7 +68,7 @@ jobs:
make dist
- name: Store Artifacts
uses: actions/upload-artifact@v4.3.6
uses: actions/upload-artifact@v4.4.0
with:
name: release
path: ${{ env.ARTIFACTS_PATH }}/
Expand Down
10 changes: 10 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# History

## 0.33.0 (2024-09-24)

- (PR #689, 2024-09-24) chore(deps): Bump pydantic from 2.7.2 to 2.8.2
- (PR #694, 2024-09-24) deps: Bump the development-dependencies group with 4 updates
- (PR #695, 2024-09-24) deps: Update `pydantic` from 2.8.2 to 2.9.2
- (PR #693, 2024-09-24) chore(deps): Bump cryptography from 42.0.8 to 43.0.1
- (PR #696, 2024-09-24) extras: Add Pydantic type for `Rut`
- (PR #687, 2024-09-24) chore: Bump the production-dependencies group with 2 updates
- (PR #697, 2024-09-24) cte: Close file object in `f29.parse_datos_obj`

## 0.32.0 (2024-08-28)

- (PR #660, 2024-08-23) chore: Bump setuptools from 65.5.1 to 70.3.0
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ dynamic = ["version"]
django = ["Django>=2.2.24"]
django-filter = ["django-filter>=24.2"]
djangorestframework = ["djangorestframework>=3.10.3,<3.16"]
pydantic = ["pydantic>=2.0"]

[project.urls]
Homepage = "https://github.com/fyntex/lib-cl-sii-python"
Expand Down
8 changes: 4 additions & 4 deletions requirements-dev.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
-c requirements.txt

black==24.8.0
build==1.0.3
build==1.2.2
bumpversion==0.5.3
coverage==7.6.1
flake8==7.1.1
isort==5.13.2
mypy==1.11.1
mypy==1.11.2
pip-tools==7.4.1
tox==4.18.0
tox==4.20.0
twine==5.1.1
types-jsonschema==4.23.0.20240813
types-pyOpenSSL==24.1.0.20240722
types-pytz==2024.1.0.20240417
types-pytz==2024.2.0.20240913
wheel==0.44.0
10 changes: 5 additions & 5 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ black==24.8.0
# via -r requirements-dev.in
bleach==5.0.1
# via readme-renderer
build==1.0.3
build==1.2.2
# via
# -r requirements-dev.in
# pip-tools
Expand Down Expand Up @@ -40,7 +40,7 @@ colorama==0.4.6
# via tox
coverage==7.6.1
# via -r requirements-dev.in
cryptography==42.0.8
cryptography==43.0.1
# via
# -c requirements.txt
# secretstorage
Expand Down Expand Up @@ -76,7 +76,7 @@ mccabe==0.7.0
# via flake8
mdurl==0.1.2
# via markdown-it-py
mypy==1.11.1
mypy==1.11.2
# via -r requirements-dev.in
mypy-extensions==1.0.0
# via
Expand Down Expand Up @@ -153,7 +153,7 @@ tomli==2.0.1
# pyproject-api
# pyproject-hooks
# tox
tox==4.18.0
tox==4.20.0
# via -r requirements-dev.in
twine==5.1.1
# via -r requirements-dev.in
Expand All @@ -163,7 +163,7 @@ types-jsonschema==4.23.0.20240813
# via -r requirements-dev.in
types-pyopenssl==24.1.0.20240722
# via -r requirements-dev.in
types-pytz==2024.1.0.20240417
types-pytz==2024.2.0.20240913
# via -r requirements-dev.in
types-setuptools==69.5.0.20240415
# via types-cffi
Expand Down
4 changes: 2 additions & 2 deletions requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# git+https://github.com/example/example.git@example-vcs-ref#egg=example-pkg[foo,bar]==1.42.3

backports-zoneinfo==0.2.1 ; python_version < "3.9" # Used by `djangorestframework`.
cryptography==42.0.8
cryptography==43.0.1
defusedxml==0.7.1
django-filter>=24.2
Django>=2.2.24
Expand All @@ -15,7 +15,7 @@ importlib-metadata==8.4.0
jsonschema==4.23.0
lxml==5.2.2
marshmallow==3.21.3
pydantic==2.7.2
pydantic==2.9.2
pyOpenSSL==24.2.1
pytz==2024.1
signxml==3.2.2
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ certifi==2024.7.4
# via signxml
cffi==1.16.0
# via cryptography
cryptography==42.0.8
cryptography==43.0.1
# via
# -r requirements.in
# pyopenssl
Expand Down Expand Up @@ -59,9 +59,9 @@ pkgutil-resolve-name==1.3.10
# via jsonschema
pycparser==2.22
# via cffi
pydantic==2.7.2
pydantic==2.9.2
# via -r requirements.in
pydantic-core==2.18.3
pydantic-core==2.23.4
# via pydantic
pyopenssl==24.2.1
# via
Expand Down
2 changes: 1 addition & 1 deletion src/cl_sii/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
"""

__version__ = '0.32.0'
__version__ = '0.33.0'
5 changes: 2 additions & 3 deletions src/cl_sii/cte/f29/parse_datos_obj.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@
_CTE_F29_DATOS_OBJ_MISSING_KEY_FIXES_PATH = (
Path(__file__).parent.parent.parent / 'data' / 'cte' / 'f29_datos_obj_missing_key_fixes.json'
)
CTE_F29_DATOS_OBJ_MISSING_KEY_FIXES: SiiCteF29DatosObjType = json.load(
open(_CTE_F29_DATOS_OBJ_MISSING_KEY_FIXES_PATH)
)
with open(_CTE_F29_DATOS_OBJ_MISSING_KEY_FIXES_PATH) as f:
CTE_F29_DATOS_OBJ_MISSING_KEY_FIXES: SiiCteF29DatosObjType = json.load(f)


def parse_sii_cte_f29_datos_obj(
Expand Down
110 changes: 110 additions & 0 deletions src/cl_sii/extras/pydantic_types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
"""
cl_sii "extras" / Pydantic types.
"""

from __future__ import annotations

import sys
from typing import Any


if sys.version_info[:2] >= (3, 9):
from typing import Annotated
else:
from typing_extensions import Annotated

try:
import pydantic
import pydantic.json_schema
except ImportError as exc: # pragma: no cover
raise ImportError("Package 'pydantic' is required to use this module.") from exc

try:
import pydantic_core
except ImportError as exc: # pragma: no cover
raise ImportError("Package 'pydantic-core' is required to use this module.") from exc

import cl_sii.rut
import cl_sii.rut.constants


class _RutPydanticAnnotation:
"""
`Annotated` wrapper that can be used as the annotation for `cl_sii.rut.Rut`
fields on `pydantic.BaseModels`, `@pydantic.dataclasses`, etc.
.. seealso::
- Handling third-party types:
https://docs.pydantic.dev/2.9/concepts/types/#handling-third-party-types
(https://github.com/pydantic/pydantic/blob/v2.9.2/docs/concepts/types.md#handling-third-party-types)
- Customizing the core schema and JSON schema:
https://docs.pydantic.dev/2.9/architecture/#customizing-the-core-schema-and-json-schema
(https://github.com/pydantic/pydantic/blob/v2.9.2/docs/architecture.md#customizing-the-core-schema-and-json-schema)
Examples:
>>> from typing import Annotated
>>> import pydantic
>>> import cl_sii.rut
>>> Rut = Annotated[cl_sii.rut.Rut, _RutPydanticAnnotation]
>>> class ExampleModel(pydantic.BaseModel):
... rut: Rut
>>>
>>> example_model_instance = ExampleModel.model_validate({'rut': '78773510-K'})
>>> import pydantic.dataclasses
>>>
>>> @pydantic.dataclasses.dataclass
... class ExampleDataclass:
... rut: Rut
>>>
>>> example_dataclass_instance = ExampleDataclass(rut='78773510-K')
>>> example_type_adapter = pydantic.TypeAdapter(Rut)
>>>
>>> example_type_adapter.validate_python('78773510-K')
Rut('78773510-K')
>>> example_type_adapter.validate_json('"78773510-K"')
Rut('78773510-K')
>>> example_type_adapter.dump_python(cl_sii.rut.Rut('78773510-K'))
'78773510-K'
>>> example_type_adapter.dump_json(cl_sii.rut.Rut('78773510-K'))
b'"78773510-K"'
"""

@classmethod
def __get_pydantic_core_schema__(
cls, source_type: Any, handler: pydantic.GetCoreSchemaHandler
) -> pydantic_core.core_schema.CoreSchema:
def validate_from_str(value: str) -> cl_sii.rut.Rut:
return cl_sii.rut.Rut(value, validate_dv=False)

from_str_schema = pydantic_core.core_schema.chain_schema(
[
pydantic_core.core_schema.str_schema(
pattern=cl_sii.rut.constants.RUT_CANONICAL_STRICT_REGEX.pattern
),
pydantic_core.core_schema.no_info_plain_validator_function(validate_from_str),
]
)

return pydantic_core.core_schema.json_or_python_schema(
json_schema=from_str_schema,
python_schema=pydantic_core.core_schema.union_schema(
[
pydantic_core.core_schema.is_instance_schema(cl_sii.rut.Rut),
from_str_schema,
]
),
serialization=pydantic_core.core_schema.plain_serializer_function_ser_schema(
lambda instance: instance.canonical
),
)


Rut = Annotated[cl_sii.rut.Rut, _RutPydanticAnnotation]
"""
Convenience type alias for Pydantic fields that represent Chilean RUTs.
"""
4 changes: 3 additions & 1 deletion src/cl_sii/rut/crypto_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import cryptography
import cryptography.x509
from cryptography.hazmat.backends.openssl import backend as crypto_x509_backend
from cryptography.hazmat.primitives.serialization import pkcs12

from . import Rut, constants

Expand All @@ -21,9 +22,10 @@ def get_subject_rut_from_certificate_pfx(pfx_file_bytes: bytes, password: Option
private_key,
x509_cert,
additional_certs,
) = crypto_x509_backend.load_key_and_certificates_from_pkcs12(
) = pkcs12.load_key_and_certificates(
data=pfx_file_bytes,
password=password.encode() if password is not None else None,
backend=crypto_x509_backend,
)
# https://cryptography.io/en/latest/hazmat/primitives/asymmetric/serialization/#cryptography.hazmat.primitives.serialization.pkcs12.load_key_and_certificates # noqa: E501

Expand Down
Loading

0 comments on commit 27f1547

Please sign in to comment.