From fe541778f140bb2c5752c654d51ad06bf8ba97db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=BB=D1=8C=D1=8F=20=D0=93=D0=BB=D0=B0=D0=B7=D1=83?= =?UTF-8?q?=D0=BD=D0=BE=D0=B2?= Date: Fri, 30 Jan 2026 23:11:42 +0300 Subject: [PATCH] changes in pyprojects fixed python version fixed linter errors in Cython path_matcher --- pyproject.toml | 4 +-- pyserve/_path_matcher.pyx | 62 +++++++++++++++++++-------------------- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 7823ac5..df994c4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,11 +3,11 @@ name = "pyserve" version = "0.9.10" description = "Python Application Orchestrator & HTTP Server - unified gateway for multiple Python web apps" authors = [ - {name = "Илья Глазунов",email = "i.glazunov@sapiens.solutions"} + {name = "Илья Глазунов",email = "lead@pyserve.org"} ] license = {text = "MIT"} readme = "README.md" -requires-python = ">=3.12" +requires-python = ">=3.12, <=3.13.7" dependencies = [ "starlette (>=0.47.3,<0.48.0)", "uvicorn[standard] (>=0.35.0,<0.36.0)", diff --git a/pyserve/_path_matcher.pyx b/pyserve/_path_matcher.pyx index 340e1ba..fb6752e 100644 --- a/pyserve/_path_matcher.pyx +++ b/pyserve/_path_matcher.pyx @@ -24,24 +24,24 @@ cdef class FastMountedPath: def __cinit__(self): self._path = "" self._path_with_slash = "/" - self._path_len = 0 - self._is_root = 1 + self._path_len = 0 + self._is_root = True self.name = "" - self.strip_path = 1 + self.strip_path = True - def __init__(self, str path, str name="", bint strip_path=True): + def __init__(self, str path, str name="", bint strip_path=True): cdef Py_ssize_t path_len - path_len = len(path) + path_len = len(path) if path_len > 1 and path[path_len - 1] == '/': path = path[:path_len - 1] self._path = path - self._path_len = len(path) - self._is_root = 1 if (path == "" or path == "/") else 0 - self._path_with_slash = path + "/" if self._is_root == 0 else "/" + self._path_len = len(path) + self._is_root = (path == "" or path == "/") + self._path_with_slash = path + "/" if not self._is_root else "/" self.name = name if name else path - self.strip_path = 1 if strip_path else 0 + self.strip_path = strip_path @property def path(self) -> str: @@ -51,20 +51,20 @@ cdef class FastMountedPath: cdef Py_ssize_t req_len if self._is_root: - return 1 + return True - req_len = len(request_path) + req_len = len(request_path) if req_len < self._path_len: - return 0 + return False if req_len == self._path_len: - return 1 if request_path == self._path else 0 + return (request_path == self._path) if request_path[self._path_len] == '/': - return 1 if request_path[:self._path_len] == self._path else 0 + return (request_path[:self._path_len] == self._path) - return 0 + return False cpdef str get_modified_path(self, str original_path): cdef str new_path @@ -108,7 +108,7 @@ cdef class FastMountManager: self._mounts = sorted(self._mounts, key=_get_path_len_neg, reverse=False) self._mount_count = len(self._mounts) - cpdef FastMountedPath get_mount(self, str request_path): + cpdef object get_mount(self, str request_path): cdef: int i FastMountedPath mount @@ -126,7 +126,7 @@ cdef class FastMountManager: Py_ssize_t path_len FastMountedPath mount - path_len = len(path) + path_len = len(path) if path_len > 1 and path[path_len - 1] == '/': path = path[:path_len - 1] @@ -135,9 +135,9 @@ cdef class FastMountManager: if mount._path == path: del self._mounts[i] self._mount_count -= 1 - return 1 + return True - return 0 + return False @property def mounts(self) -> list: @@ -164,27 +164,27 @@ cdef class FastMountManager: cpdef bint path_matches_prefix(str request_path, str mount_path): cdef: - Py_ssize_t mount_len = len(mount_path) - Py_ssize_t req_len = len(request_path) + Py_ssize_t mount_len = len(mount_path) + Py_ssize_t req_len = len(request_path) if mount_len == 0 or mount_path == "/": - return 1 + return True if req_len < mount_len: - return 0 + return False if req_len == mount_len: - return 1 if request_path == mount_path else 0 + return (request_path == mount_path) if request_path[mount_len] == '/': - return 1 if request_path[:mount_len] == mount_path else 0 + return (request_path[:mount_len] == mount_path) - return 0 + return False cpdef str strip_path_prefix(str original_path, str mount_path): cdef: - Py_ssize_t mount_len = len(mount_path) + Py_ssize_t mount_len = len(mount_path) str result if mount_len == 0 or mount_path == "/": @@ -198,11 +198,11 @@ cpdef str strip_path_prefix(str original_path, str mount_path): return result -cpdef tuple match_and_modify_path(str request_path, str mount_path, bint strip_path=True): +cpdef tuple match_and_modify_path(str request_path, str mount_path, bint strip_path=True): cdef: - Py_ssize_t mount_len = len(mount_path) - Py_ssize_t req_len = len(request_path) - bint is_root = 1 if (mount_len == 0 or mount_path == "/") else 0 + Py_ssize_t mount_len = len(mount_path) + Py_ssize_t req_len = len(request_path) + bint is_root = (mount_len == 0 or mount_path == "/") str modified if is_root: