-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Compatibility lib for older python versions (#160)
- Loading branch information
Showing
19 changed files
with
139 additions
and
230 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import sys | ||
|
||
__all__ = ["Concatenate", "ParamSpec", "TypeGuard", "UnionType", "StrEnum", "tomllib"] | ||
|
||
# PORT: Remove when stop supporting 3.9 | ||
# Concatenate was added in Python 3.10 | ||
# https://docs.python.org/3/library/typing.html#typing.Concatenate | ||
if sys.version_info >= (3, 10): | ||
from typing import Concatenate | ||
else: | ||
from typing_extensions import Concatenate | ||
|
||
|
||
# PORT: Remove when stop supporting 3.9 | ||
# ParamSpec was added in Python 3.10 | ||
# https://docs.python.org/3/library/typing.html#typing.ParamSpec | ||
if sys.version_info >= (3, 10): | ||
from typing import ParamSpec | ||
else: | ||
from typing_extensions import ParamSpec | ||
|
||
|
||
# PORT: Remove when stop supporting 3.9 | ||
# TypeGuard was added in Python 3.10 | ||
# https://docs.python.org/3/library/typing.html#typing.TypeGuard | ||
if sys.version_info >= (3, 10): | ||
from typing import TypeGuard | ||
else: | ||
from typing_extensions import TypeGuard | ||
|
||
|
||
# PORT: Remove when stop supporting 3.9 | ||
# UnionType was added in Python 3.10 | ||
# https://docs.python.org/3/library/stdtypes.html#types-union | ||
if sys.version_info >= (3, 10): | ||
from types import UnionType | ||
else: | ||
from typing import Union as UnionType | ||
|
||
|
||
# PORT: Remove when stop supporting 3.10 | ||
# StrEnum was added in Python 3.11 | ||
# https://docs.python.org/3/library/enum.html#enum.StrEnum | ||
if sys.version_info >= (3, 11): | ||
from enum import StrEnum | ||
else: | ||
from enum import Enum | ||
|
||
class StrEnum(str, Enum): | ||
@staticmethod | ||
def _generate_next_value_(name, start, count, last_values): | ||
return name.lower() | ||
|
||
|
||
# PORT: Remove when stop supporting 3.10 | ||
# Tomllib was added in Python 3.11 | ||
# https://docs.python.org/3/library/tomllib.html | ||
if sys.version_info >= (3, 11): # PORT: Remove when stop supporting 3.10 | ||
import tomllib | ||
else: | ||
try: | ||
import tomli | ||
|
||
tomllib = tomli | ||
except ModuleNotFoundError: | ||
tomllib = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,10 @@ | ||
import enum | ||
import sys | ||
|
||
if sys.version_info < (3, 11): # PORT: Remove when stop supporting 3.10 # pragma: no cover | ||
|
||
class StrEnum(str, enum.Enum): | ||
@staticmethod | ||
def _generate_next_value_(name, start, count, last_values): | ||
return name.lower() | ||
|
||
enum.StrEnum = StrEnum # type: ignore | ||
from flama import compat | ||
|
||
__all__ = ["PaginationType"] | ||
|
||
|
||
class PaginationType(enum.StrEnum): # type: ignore # PORT: Remove this comment when stop supporting 3.10 | ||
class PaginationType(compat.StrEnum): # PORT: Replace compat when stop supporting 3.10 | ||
page_number = enum.auto() | ||
limit_offset = enum.auto() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.