Skip to content
Merged
Show file tree
Hide file tree
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: 2 additions & 2 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
max-parallel: 15
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', 'pypy-3.9', 'pypy-3.10']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', 'pypy-3.9', 'pypy-3.10']
test-type: ['standalone', 'cluster']
connection-type: ['hiredis', 'plain']
env:
Expand Down Expand Up @@ -187,7 +187,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', 'pypy-3.9', 'pypy-3.10']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', 'pypy-3.9', 'pypy-3.10']
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
Expand Down
14 changes: 7 additions & 7 deletions dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
black==24.3.0
black
cachetools
click==8.0.4
flake8-isort==6.0.0
flake8==5.0.4
flynt~=0.69.0
invoke==1.7.3
mock==4.0.3
click
flake8-isort
flake8
flynt
invoke
mock
packaging>=20.4
pytest
pytest-asyncio
Expand Down
32 changes: 16 additions & 16 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,56 +25,56 @@ def build_docs(c):


@task
def linters(c):
def linters(c, color=False):
"""Run code linters"""
run("flake8 tests valkey")
run("black --target-version py37 --check --diff tests valkey")
run("isort --check-only --diff tests valkey")
run(f"flake8 --color {'always' if color else 'never'} tests valkey")
run(f"black {'--color' if color else ''} --target-version py37 --check --diff tests valkey")
run(f"isort {'--color' if color else ''} --check-only --diff tests valkey")
run("vulture valkey whitelist.py --min-confidence 80")
run("flynt --fail-on-change --dry-run tests valkey")


@task
def all_tests(c):
def all_tests(c, color=False):
"""Run all linters, and tests in valkey-py."""
linters(c)
tests(c)
linters(c, color=color)
tests(c, color=color)


@task
def tests(c, uvloop=False, protocol=2):
def tests(c, uvloop=False, protocol=2, color=False):
"""Run the valkey-py test suite against the current python,
with and without hiredis.
"""
print("Starting Valkey tests")
standalone_tests(c, uvloop=uvloop, protocol=protocol)
cluster_tests(c, uvloop=uvloop, protocol=protocol)
standalone_tests(c, uvloop=uvloop, protocol=protocol, color=color)
cluster_tests(c, uvloop=uvloop, protocol=protocol, color=color)


@task
def standalone_tests(c, uvloop=False, protocol=2):
def standalone_tests(c, uvloop=False, protocol=2, color=False):
"""Run tests against a standalone valkey instance"""
if uvloop:
run(
f"pytest --protocol={protocol} --cov=./ --cov-report=xml:coverage_valkey.xml -W always -m 'not onlycluster' --uvloop --junit-xml=standalone-uvloop-results.xml"
f"pytest --color={'yes' if color else 'no'} --protocol={protocol} --cov=./ --cov-report=xml:coverage_valkey.xml -W always -m 'not onlycluster' --uvloop --junit-xml=standalone-uvloop-results.xml"
)
else:
run(
f"pytest --protocol={protocol} --cov=./ --cov-report=xml:coverage_valkey.xml -W always -m 'not onlycluster' --junit-xml=standalone-results.xml"
f"pytest --color={'yes' if color else 'no'} --protocol={protocol} --cov=./ --cov-report=xml:coverage_valkey.xml -W always -m 'not onlycluster' --junit-xml=standalone-results.xml"
)


@task
def cluster_tests(c, uvloop=False, protocol=2):
def cluster_tests(c, uvloop=False, protocol=2, color=False):
"""Run tests against a valkey cluster"""
cluster_url = "valkey://localhost:16379/0"
if uvloop:
run(
f"pytest --protocol={protocol} --cov=./ --cov-report=xml:coverage_cluster.xml -W always -m 'not onlynoncluster and not valkeymod' --valkey-url={cluster_url} --junit-xml=cluster-uvloop-results.xml --uvloop"
f"pytest --color={'yes' if color else 'no'} --protocol={protocol} --cov=./ --cov-report=xml:coverage_cluster.xml -W always -m 'not onlynoncluster and not valkeymod' --valkey-url={cluster_url} --junit-xml=cluster-uvloop-results.xml --uvloop"
)
else:
run(
f"pytest --protocol={protocol} --cov=./ --cov-report=xml:coverage_clusteclient.xml -W always -m 'not onlynoncluster and not valkeymod' --valkey-url={cluster_url} --junit-xml=cluster-results.xml"
f"pytest --color={'yes' if color else 'no'} --protocol={protocol} --cov=./ --cov-report=xml:coverage_clusteclient.xml -W always -m 'not onlynoncluster and not valkeymod' --valkey-url={cluster_url} --junit-xml=cluster-results.xml"
)


Expand Down
2 changes: 1 addition & 1 deletion tests/test_asyncio/test_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,4 +237,4 @@ def __init__(self, *args, **kwargs):
pass

lock = r.lock("foo", lock_class=MyLock)
assert type(lock) == MyLock
assert isinstance(lock, MyLock)
2 changes: 1 addition & 1 deletion tests/test_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,4 +257,4 @@ def __init__(self, *args, **kwargs):
pass

lock = r.lock("foo", lock_class=MyLock)
assert type(lock) == MyLock
assert isinstance(lock, MyLock)
2 changes: 1 addition & 1 deletion valkey/_parsers/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ def parse_geosearch_generic(response, **options):
except KeyError: # it means the command was sent via execute_command
return response

if type(response) != list:
if not isinstance(response, list):
response_list = [response]
else:
response_list = response
Expand Down
3 changes: 0 additions & 3 deletions valkey/commands/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1380,9 +1380,6 @@ def failover(self):
)


AsyncManagementCommands = ManagementCommands


class AsyncManagementCommands(ManagementCommands):
async def command_info(self, **kwargs) -> None:
return super().command_info(**kwargs)
Expand Down
2 changes: 1 addition & 1 deletion valkey/commands/timeseries/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def __init__(self, args):
self.chunk_size = response["chunkSize"]
if "duplicatePolicy" in response:
self.duplicate_policy = response["duplicatePolicy"]
if type(self.duplicate_policy) == bytes:
if isinstance(self.duplicate_policy, bytes):
self.duplicate_policy = self.duplicate_policy.decode()

def get(self, item):
Expand Down