Skip to content

Commit

Permalink
feat: support down to python 3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
CNSeniorious000 committed Jan 25, 2024
1 parent 6d20e0e commit dba436e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.10", "3.11", "3.12", "pypy3.10"]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "pypy3.6", "pypy3.7", "pypy3.8", "pypy3.9", "pypy3.10"]

steps:
- uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[project]
name = "literal-dict"
version = "0.0.1.dev1"
version = "1.0.0"
description = "Use JavaScript-like object definition syntax in Python"
authors = [{ name = "Muspi Merol", email = "me@muspimerol.site" }]
dependencies = []
requires-python = ">=3.10"
requires-python = ">=3.6"
readme = "README.md"
license = { text = "MIT" }

Expand Down
8 changes: 4 additions & 4 deletions src/literal_dict/__init__.py → src/literal_dict.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
from inspect import currentframe
from typing import Generic, Mapping, Sequence, TypeVar, cast
from typing import Generic, Mapping, Sequence, Type, TypeVar, Union, cast

T = TypeVar("T")
D = TypeVar("D", bound=Mapping)


class DictBuilder(Generic[D]):
def __init__(self, mapping_type: type[D] = dict):
def __init__(self, mapping_type: Type[D] = dict):
self.mapping_type = mapping_type

def __getitem__(self, args: slice | T | Sequence[slice | T]) -> D:
def __getitem__(self, args: Union[slice, T, Sequence[Union[slice, T]]]) -> D:
if not isinstance(args, tuple):
args = (args,) # type: ignore

Expand All @@ -20,7 +20,7 @@ def __getitem__(self, args: slice | T | Sequence[slice | T]) -> D:
assert caller_frame, "Unable to get the caller's frame."

obj = {}
for arg in cast(Sequence[slice | T], args):
for arg in cast(Sequence[Union[slice, T]], args):
if isinstance(arg, slice):
assert isinstance(arg.start, str), "Key must be a string"
obj[arg.start] = arg.stop
Expand Down

0 comments on commit dba436e

Please sign in to comment.