Skip to content

Commit

Permalink
chore(signature model): fix python 3.8 compat
Browse files Browse the repository at this point in the history
  • Loading branch information
Goldziher committed Jul 14, 2023
1 parent 426d157 commit 27ab921
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 35 deletions.
5 changes: 2 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ repos:
exclude: "test_apps|tools|docs|tests/examples|tests/docker_service_fixtures"
additional_dependencies:
[
polyfactory,
"git+https://github.com/jcrist/msgspec.git",
msgspec>=0.17.0,
aiosqlite,
annotated_types,
async_timeout,
Expand Down Expand Up @@ -130,7 +129,7 @@ repos:
exclude: "test_apps|tools|docs|_openapi|tests/examples|tests/docker_service_fixtures"
additional_dependencies:
[
"git+https://github.com/jcrist/msgspec.git",
msgspec>=0.17.0,
aiosqlite,
annotated_types,
async_timeout,
Expand Down
5 changes: 3 additions & 2 deletions litestar/_signature/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from __future__ import annotations

import re
from typing import TYPE_CHECKING, Any, ClassVar, Literal, Optional, Sequence, Set, TypedDict, Union, cast
from typing import TYPE_CHECKING, Any, ClassVar, Dict, Literal, Optional, Sequence, Set, TypedDict, Union, cast

from msgspec import NODEFAULT, Meta, Struct, ValidationError, convert, defstruct
from msgspec.structs import asdict
Expand Down Expand Up @@ -59,9 +59,10 @@ class ErrorMessage(TypedDict):
class SignatureModel(Struct):
"""Model that represents a function signature that uses a msgspec specific type or types."""

# NOTE: we have to use Set and Dict here because python 3.8 goes haywire if we use 'set' and 'dict'
dependency_name_set: ClassVar[Set[str]]
fields: ClassVar[Dict[str, FieldDefinition]]
return_annotation: ClassVar[Any]
fields: ClassVar[dict[str, FieldDefinition]]

@classmethod
def _create_exception(cls, connection: ASGIConnection, messages: list[ErrorMessage]) -> Exception:
Expand Down
2 changes: 1 addition & 1 deletion litestar/serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def _enc_constrained_date(date: ConstrainedDate) -> str:
return date.isoformat()


def _enc_pattern(pattern: Pattern) -> Any:
def _enc_pattern(pattern: Pattern[str]) -> Any:
return pattern.pattern


Expand Down
31 changes: 3 additions & 28 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ importlib-resources = { version = ">=5.12.0", python = "<3.9" }
jinja2 = { version = ">=3.1.2", optional = true }
jsbeautifier = { version = "*", optional = true }
mako = { version = ">=1.2.4", optional = true }
msgspec = { git = "https://github.com/jcrist/msgspec.git", branch = "main" }
msgspec = ">=0.17.0"
multidict = ">=6.0.2"
opentelemetry-instrumentation-asgi = { version = "*", optional = true }
picologging = { version = "*", optional = true }
Expand Down

0 comments on commit 27ab921

Please sign in to comment.