Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #203 from seandstewart/sean/198/update-typing-exte…
Browse files Browse the repository at this point in the history
…nsions

Update typing-extensions, plus a few fixes for other breaking changes in Python.
  • Loading branch information
seandstewart authored Apr 26, 2023
2 parents 05babfb + 6534b16 commit 97eec30
Show file tree
Hide file tree
Showing 9 changed files with 1,379 additions and 1,126 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jobs:
matrix:
os: [ubuntu-latest]
python-version: ["3.9"]
poetry-version: ["1.4.2"]

steps:
- uses: actions/checkout@v2
Expand All @@ -22,12 +23,10 @@ jobs:
- name: Display Python version
run: python -c "import sys; print(f'Python {sys.version} on {sys.platform}')"

- name: Install Linux dependencies
run: |
./.github/ubuntu-install.sh
- name: Install Poetry
uses: abatilo/[email protected]
with:
poetry-version: ${{ matrix.poetry-version }}

- name: Cache Poetry virtualenv
uses: actions/cache@v1
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/pythonpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.7", "3.8", "3.9", "3.10.0-alpha - 3.10"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v1
- name: Set up Python-${{ matrix.python-version }} (Platform ${{ matrix.os }})
Expand All @@ -38,6 +38,8 @@ jobs:
python-version: 3.7
- name: Install Poetry
uses: abatilo/[email protected]
with:
poetry-version: 1.4.2
- name: Build sdist
run: poetry build -f sdist
- name: Store dist artifacts
Expand Down
8 changes: 2 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
python-version: ["3.7", "3.8", "3.9", "3.10"]
poetry-version: ["1.1.8"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
poetry-version: ["1.4.2"]
env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python-version }}
Expand All @@ -27,10 +27,6 @@ jobs:
- name: Display Python version
run: python -c "import sys; print(f'Python {sys.version} on {sys.platform}')"

- name: Install Linux dependencies
if: startsWith(matrix.os, 'ubuntu')
run: |
./.github/ubuntu-install.sh
- name: Install macOS dependencies
if: startsWith(matrix.os, 'macos')
run: |
Expand Down
2,438 changes: 1,329 additions & 1,109 deletions poetry.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tool.poetry]
name = "typical"
packages = [{include = "typic"}]
version = "2.8.0"
version = "2.8.1"
description = "Typical: Python's Typing Toolkit."
authors = ["Sean Stewart <[email protected]>"]
license = "MIT"
Expand Down Expand Up @@ -35,7 +35,7 @@ pendulum = "^2.1"
fastjsonschema = {version = "^2.14", optional = true}
ujson = {version = ">=2.0", optional = true}
orjson = {version = "^3.6.3", optional = true}
typing-extensions = {version = "^3.10.0", python = "<3.10"}
typing-extensions = {version = "^4", python = "<3.10"}
# tests
pytest = {version = "^6.2", optional = true}
pytest-cov = {version = "^2.8", optional = true}
Expand Down Expand Up @@ -158,7 +158,7 @@ requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[bumpver]
current_version = "v2.8.0"
current_version = "v2.8.1"
version_pattern = "vMAJOR.MINOR.PATCH[-TAGNUM]"
commit_message = "bump version to {new_version} [ci skip]"
tag = false
Expand Down
2 changes: 1 addition & 1 deletion typic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
al = typed


__version__ = "2.8.0"
__version__ = "2.8.1"
32 changes: 30 additions & 2 deletions typic/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,37 @@
)

try:
from typing import Final, TypedDict, Literal, Protocol, Generic, TypeGuard, get_origin, get_args # type: ignore
from typing import Final # type: ignore
except ImportError: # pragma: nocover
from typing_extensions import Final, TypedDict, Literal, Protocol, Generic, TypeGuard, get_origin, get_args # type: ignore
from typing_extensions import Final # type: ignore
try:
from typing import TypedDict # type: ignore
except ImportError: # pragma: nocover
from typing_extensions import TypedDict # type: ignore
try:
from typing import Literal # type: ignore
except ImportError: # pragma: nocover
from typing_extensions import Literal # type: ignore
try:
from typing import Protocol # type: ignore
except ImportError: # pragma: nocover
from typing_extensions import Protocol # type: ignore
try:
from typing import Generic # type: ignore
except ImportError: # pragma: nocover
from typing_extensions import Generic # type: ignore
try:
from typing import TypeGuard # type: ignore
except ImportError: # pragma: nocover
from typing_extensions import TypeGuard # type: ignore
try:
from typing import get_origin # type: ignore
except ImportError: # pragma: nocover
from typing_extensions import get_origin # type: ignore
try:
from typing import get_args # type: ignore
except ImportError: # pragma: nocover
from typing_extensions import get_args # type: ignore
try:
from typing import ForwardRef # type: ignore
except ImportError: # pragma: nocover
Expand Down
6 changes: 6 additions & 0 deletions typic/gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ class Keyword(str, enum.Enum):
FRM = "from"
DEC = "@"

def __str__(self):
return self.value

def __repr__(self):
return self.value


@slotted(dict=False)
@dataclasses.dataclass(frozen=True)
Expand Down
2 changes: 2 additions & 0 deletions typic/serde/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,8 @@ def protocols(self, obj, *, strict: bool = False) -> SerdeProtocolsT:
fields = {f.name: f for f in dataclasses.fields(obj)}
ann = {}
for name in params.keys() | hints.keys():
if name == "return":
continue
param = params.get(name)
hint = hints.get(name)
field = fields.get(name)
Expand Down

0 comments on commit 97eec30

Please sign in to comment.