Skip to content

query: Fix type hints to ensure compatibility with Python 3.8 #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.1.3

Fixed issues with type hints when using Python 3.8.

## 0.1.2

Support negative floating point values in responses.
9 changes: 5 additions & 4 deletions src/skytable_py/query.py
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@
# limitations under the License.

from abc import ABC
from typing import Tuple
# internal
from .exception import ClientException

@@ -36,7 +37,7 @@ def get_param_count(self) -> int:


class SkyhashParameter(ABC):
def encode_self(self) -> tuple[bytes, int]: pass
def encode_self(self) -> Tuple[bytes, int]: pass


class UInt(SkyhashParameter):
@@ -45,19 +46,19 @@ def __init__(self, v: int) -> None:
raise ClientException("unsigned int can't be negative")
self.v = v

def encode_self(self) -> tuple[bytes, int]:
def encode_self(self) -> Tuple[bytes, int]:
return (f"\x02{self.v}\n".encode(), 1)


class SInt(SkyhashParameter):
def __init__(self, v: int) -> None:
self.v = v

def encode_self(self) -> tuple[bytes, int]:
def encode_self(self) -> Tuple[bytes, int]:
return (f"\x03{self.v}\n".encode(), 1)


def encode_parameter(parameter: any) -> tuple[bytes, int]:
def encode_parameter(parameter: any) -> Tuple[bytes, int]:
encoded = None
if isinstance(parameter, SkyhashParameter):
return parameter.encode_self()