Skip to content

Commit

Permalink
Merge pull request #29 from xyngular/josho/pyhton-3.12-support
Browse files Browse the repository at this point in the history
feat: update to support Python 3.12 + xurls 1.0 release.
  • Loading branch information
joshorr authored Dec 20, 2023
2 parents 60f9397 + 7663a28 commit 77acdd9
Show file tree
Hide file tree
Showing 8 changed files with 420 additions and 411 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Provides easy way to map dict to/from Full-Fledged 'JsonModel' object.

![PythonSupport](https://img.shields.io/static/v1?label=python&message=%203.8|%203.9|%203.10|%203.11&color=blue?style=flat-square&logo=python)
![PythonSupport](https://img.shields.io/static/v1?label=python&message=%203.10|%203.11|%203.12&color=blue?style=flat-square&logo=python)
![PyPI version](https://badge.fury.io/py/xmodel.svg?)

## Documentation
Expand Down
795 changes: 401 additions & 394 deletions poetry.lock

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ classifiers = [
]

[tool.poetry.dependencies]
python = "^3.8"
python = "^3.10"
typing-inspect = "^0"
xloop = "^1.0.1"
xinject = "^1.4.0"
xsentinels = "^1.2.1"
xurls = "^0.2.0"
xurls = "^1.0.0"
ciso8601 = "^2.3.0"
xbool = "^1.1.0"


[tool.poetry.group.dev.dependencies]
Expand All @@ -35,6 +36,7 @@ mkdocs = "^1.4.2"
mkdocs-material = "^9.0.12"
mike = "^1.1.2"
tomlkit = "^0.11.7"
setuptools = "^69.0.2"

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand Down
2 changes: 1 addition & 1 deletion xmodel/base/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class BaseModel(ABC):
.. note:: In the case of `base_url` example above, it's the base-url-endpoint for the model.
If you want to know more about that see `xmodel.rest.RestClient.url_for_endpoint`.
It has details on how the final request `xurls.url.URL` is constructed.
It has details on how the final request `xurls.url.Url` is constructed.
This class also allows you to more easily with with JSON data via:
Expand Down
4 changes: 2 additions & 2 deletions xmodel/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from typing import Union, TYPE_CHECKING, Type, TypeVar, Generic, Dict, Any
from xsentinels.null import Null, NullType, Nullable
from xmodel.errors import XModelError
from distutils.util import strtobool
from decimal import Decimal
from xbool import bool_value

_to_obj_directions = {Converter.Direction.from_json, Converter.Direction.to_model}
Direction = Converter.Direction
Expand Down Expand Up @@ -126,7 +126,7 @@ def __call__(
class ConvertBasicBool(ConvertBasicType[bool]):
def convert_basic_value(self, value) -> T:
if isinstance(value, str):
return strtobool(value)
return bool_value(value)
return super().convert_basic_value(value)

def __init__(self):
Expand Down
8 changes: 4 additions & 4 deletions xmodel/remote/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def get_via_id(
all of them and checking the `first_name` attribute yourself if you expect
only a few of these objects to actually match.
These won't be split up into segments [to keep URL/Request smaller] like the
These won't be split up into segments [to keep Url/Request smaller] like the
id/keys are.
We are not able to use the id-cache if these are provided, we may always have
to go to the API. This may change at some point in the future [by executing the
Expand Down Expand Up @@ -330,7 +330,7 @@ def get_via_id(
return None

# We can assume at this point a list of ID's to get and a list of objects to return.
# We only want to do about 100 at a time [due to URL length limits in production].
# We only want to do about 100 at a time [due to Url length limits in production].

results = []
id_list = []
Expand Down Expand Up @@ -362,8 +362,8 @@ def get_via_id(
elif obj_id and type(obj_id) is str:
# I think we can assume people using our method will NOT pass in comma
# separated values, if there is a comma they would want it to be part
# of the ID [ie: they are passing us lists/dicts here, and we let the URL
# formatter deal with how to encode that into the URL [ie: by comma, etc]...
# of the ID [ie: they are passing us lists/dicts here, and we let the Url
# formatter deal with how to encode that into the Url [ie: by comma, etc]...
#
# todo: Talk to Kaden, see why he put this in here originally.
# Probably remove the comma splitting...
Expand Down
4 changes: 2 additions & 2 deletions xmodel/remote/client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import weakref
from xurls.url import (
URLStr, Query
UrlStr, Query
)
from xinject import Dependency, XContext
from xmodel.common.types import FieldNames
Expand Down Expand Up @@ -175,7 +175,7 @@ def delete_objs(self, objs: Sequence[M]):
raise NotImplementedError(f"Implement `delete_objs()` on ({type(self)}).")

def send_objs(
self, objs: Sequence[M], *, url: URLStr = None, send_limit: int = None
self, objs: Sequence[M], *, url: UrlStr = None, send_limit: int = None
):
raise NotImplementedError(f"Implement `send_objs()` on ({type(self)}).")

Expand Down
10 changes: 5 additions & 5 deletions xmodel/remote/response_state.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Dict, List, Any, Optional, Union, TypeVar, Generic
# noinspection PyPep8Naming
from enum import Enum, auto as EnumAuto # noqa
from xurls.url import URL
from xurls.url import Url
from abc import ABC, abstractmethod

T = TypeVar("T")
Expand All @@ -19,7 +19,7 @@ class ErrorHandler(Generic[T], ABC):
See `HttpErrorHandler.__call__` for details.
"""
@abstractmethod
def __call__(self, obj: T, http: "ResponseState[T]", url: URL) -> bool:
def __call__(self, obj: T, http: "ResponseState[T]", url: Url) -> bool:
"""
Signature of the call that happens for an HttpErrorHandler.
Expand All @@ -38,9 +38,9 @@ def __call__(self, obj: T, http: "ResponseState[T]", url: URL) -> bool:
http (ResponseState): The `xmodel.remote.api.RemoteApi.response_state` object,
passed in here for convenience.
url (xurls.URL): url that was used. You can ask the url for the http method that
was used, there will always only be exactly ONE method assigned to the URL you get
here (`xurls.URL.methods`).
url (xurls.Url): url that was used. You can ask the url for the http method that
was used, there will always only be exactly ONE method assigned to the Url you get
here (`xurls.Url.methods`).
"""
return False

Expand Down

0 comments on commit 77acdd9

Please sign in to comment.