Skip to content

Commit

Permalink
Merge pull request #460 from yukinarit/drop-python3.7
Browse files Browse the repository at this point in the history
Drop python3.7
  • Loading branch information
yukinarit authored Jan 7, 2024
2 parents 514a38a + 47ab8d8 commit 10e660a
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
matrix:
# Remove pypy-3.8 until it supports numpy
python-version: ["3.8", "3.9", "3.10", "3.11"] # "pypy-3.8"
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] # "pypy-3.8"
steps:
- uses: actions/checkout@v3
- name: Install poetry
Expand Down
7 changes: 1 addition & 6 deletions examples/literal.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import sys
from dataclasses import dataclass

from serde.compat import SerdeError

if sys.version_info[:2] == (3, 7):
from typing_extensions import Literal
else:
from typing import Literal
from typing import Literal

from serde import serde
from serde.json import from_json, to_json
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ numpy = [
{ version = ">1.21.0", markers = "python_version ~= '3.8.0' and (extra == 'numpy' or extra == 'all')", optional = true },
{ version = ">1.21.0", markers = "python_version ~= '3.9.0' and (extra == 'numpy' or extra == 'all')", optional = true },
{ version = ">1.22.0", markers = "python_version ~= '3.10' and (extra == 'numpy' or extra == 'all')", optional = true },
{ version = ">1.22.0", markers = "python_version ~= '3.11' and (extra == 'numpy' or extra == 'all')", optional = true },
{ version = ">1.22.0", markers = "python_version ~= '3.12' and (extra == 'numpy' or extra == 'all')", optional = true },
]
orjson = { version = "*", markers = "extra == 'orjson' or extra == 'all'", optional = true }
plum-dispatch = "^2"
Expand Down
7 changes: 0 additions & 7 deletions serde/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@
import typing_inspect
from typing_extensions import Type, TypeGuard

if sys.version_info[:2] == (3, 7):
Literal = typing_extensions.Literal
else:
Literal = typing.Literal

# Create alias for `dataclasses.Field` because `dataclasses.Field` is a generic
# class since 3.9 but is not in 3.7 and 3.8.
if sys.version_info[:2] <= (3, 8):
Expand Down Expand Up @@ -842,8 +837,6 @@ def is_literal(typ: Type[Any]) -> bool:
False
"""
origin = get_origin(typ)
if sys.version_info[:2] == (3, 7):
return origin is typing_extensions.Literal
return origin is not None and origin is typing.Literal


Expand Down
2 changes: 1 addition & 1 deletion serde/de.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
overload,
Union,
Sequence,
Literal,
Iterable,
)

import jinja2
from typing_extensions import Type, dataclass_transform

from .compat import (
Literal,
SerdeError,
SerdeSkip,
T,
Expand Down
2 changes: 1 addition & 1 deletion serde/se.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
TypeVar,
Iterable,
Union,
Literal,
)

import jinja2
from typing_extensions import dataclass_transform

from .compat import (
Literal,
SerdeError,
SerdeSkip,
T,
Expand Down
3 changes: 1 addition & 2 deletions tests/test_compat.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import sys
from dataclasses import dataclass
from datetime import datetime
from typing import Any, Dict, Generic, List, NewType, Optional, Set, Tuple, TypeVar, Union
from typing import Any, Dict, Generic, List, NewType, Optional, Set, Tuple, TypeVar, Union, Literal

import pytest

import serde
from serde.compat import (
Literal,
get_generic_arg,
is_dict,
is_generic,
Expand Down
8 changes: 1 addition & 7 deletions tests/test_literal.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import logging
import sys
from dataclasses import dataclass
from typing import Dict, List, Tuple

if sys.version_info[:2] == (3, 7):
from typing_extensions import Literal
else:
from typing import Literal
from typing import Dict, List, Tuple, Literal

import pytest

Expand Down
15 changes: 13 additions & 2 deletions tests/test_union.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,19 @@
import sys
from dataclasses import dataclass
from ipaddress import IPv4Address
from typing import Dict, FrozenSet, Generic, List, NewType, Optional, Tuple, TypeVar, Union, Any
from typing import (
Dict,
FrozenSet,
Generic,
List,
NewType,
Optional,
Tuple,
TypeVar,
Union,
Any,
Literal,
)
from uuid import UUID

import pytest
Expand All @@ -20,7 +32,6 @@
AdjacentTagging,
Untagged,
)
from serde.compat import Literal
from serde.json import from_json, to_json

logging.basicConfig(level=logging.WARNING)
Expand Down

0 comments on commit 10e660a

Please sign in to comment.