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
21 changes: 12 additions & 9 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,19 @@ on:

jobs:
build:
services:
redis:
image: redis
ports: ['6379:6379']
memcached:
image: memcached
ports: ['11211:11211']

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["2.7", "3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v2
Expand All @@ -29,19 +37,14 @@ jobs:
run: |
sudo apt-get install libmemcached-dev
python -m pip install --upgrade pip
python --version | grep '3.' && python -m pip install black
python -m pip install ruff
python -m pip install -e '.[tests]'
- name: Lint with black
- name: Lint with ruff
run: |
black --check ring tests setup.py
if: matrix.python-version != '2.7'
- name: Start containers
run: docker-compose -f "docker-compose.yml" up -d --build
ruff format --diff ring tests setup.py
- name: Test with pytest
run: |
pytest
- name: Stop containers
run: docker-compose -f "docker-compose.yml" down

- name: Codecov
run: bash <(curl -s https://codecov.io/bash)
1 change: 1 addition & 0 deletions ring/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Common ring decorators are aliased in this level as shortcuts.
"""

import ring.coder # noqa
from ring.__version__ import __version__ # noqa
from ring.func import lru, dict, shelve, disk, memcache, redis, redis_hash
Expand Down
3 changes: 2 additions & 1 deletion ring/coder.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Coder is a configurable layer that provides ways to encode raw data and decode
stored cache data.
"""

import abc
import six
from collections import namedtuple
Expand Down Expand Up @@ -105,7 +106,7 @@ def get_or_coderize(self, raw_coder):
if coder is None:
if isinstance(raw_coder, str): # py2 support
raise TypeError(
"The given coder is not a registered name in coder " "registry."
"The given coder is not a registered name in coder registry."
)
coder = coderize(raw_coder)
return coder
Expand Down
3 changes: 2 additions & 1 deletion ring/django.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
""":mod:`ring.django` --- Django support
========================================
"""

from __future__ import absolute_import

import warnings
Expand Down Expand Up @@ -47,7 +48,7 @@ def transform_cache_page_args(wire, rules, args, kwargs):
raw_request = args[0]
if isinstance(raw_request, HttpRequest):
request = raw_request
elif type(raw_request) == tuple:
elif type(raw_request) is tuple:
template_request, path_hint = raw_request
if not isinstance(template_request, HttpRequest):
raise TypeError
Expand Down
1 change: 1 addition & 0 deletions ring/func/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Ring object factory functions are aggregated in this module.
"""

from __future__ import absolute_import
from ring.func import sync

Expand Down
29 changes: 14 additions & 15 deletions ring/func/asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
This module includes building blocks and storage implementations of **Ring**
factories for :mod:`asyncio`.
"""

import sys
from functools import wraps, partial

Expand Down Expand Up @@ -174,9 +175,7 @@ class CacheUserInterface(fbase.BaseUserInterface):
details.
"""

@fbase.interface_attrs(
return_annotation=lambda a: Optional[a.get("return", Any)]
) # noqa: F722
@fbase.interface_attrs(return_annotation=lambda a: Optional[a.get("return", Any)]) # noqa: F722
async def get(self, wire, **kwargs):
key = self.key(wire, **kwargs)
try:
Expand Down Expand Up @@ -565,7 +564,7 @@ def dict(
coder=None,
user_interface=CacheUserInterface,
storage_class=None,
**kwargs
**kwargs,
):
""":class:`dict` interface for :mod:`asyncio`.

Expand All @@ -587,7 +586,7 @@ def dict(
miss_value=None,
expire_default=expire,
coder=coder,
**kwargs
**kwargs,
)


Expand All @@ -599,7 +598,7 @@ def aiomcache(
user_interface=(CacheUserInterface, BulkInterfaceMixin),
storage_class=AiomcacheStorage,
key_encoding="utf-8",
**kwargs
**kwargs,
):
"""Memcached_ interface for :mod:`asyncio`.

Expand Down Expand Up @@ -639,7 +638,7 @@ def aiomcache(
coder=coder,
key_encoding=key_encoding,
key_refactor=key_refactor,
**kwargs
**kwargs,
)


Expand All @@ -650,7 +649,7 @@ def aioredis1(
coder=None,
user_interface=(CacheUserInterface, BulkInterfaceMixin),
storage_class=Aioredis1Storage,
**kwargs
**kwargs,
):
"""Redis interface for :mod:`asyncio`.

Expand Down Expand Up @@ -708,7 +707,7 @@ def aioredis1(
miss_value=None,
expire_default=expire,
coder=coder,
**kwargs
**kwargs,
)


Expand All @@ -719,7 +718,7 @@ def aioredis1_hash(
coder=None,
user_interface=(CacheUserInterface, BulkInterfaceMixin),
storage_class=Aioredis1HashStorage,
**kwargs
**kwargs,
):
"""Redis interface for :mod:`asyncio`.

Expand Down Expand Up @@ -772,7 +771,7 @@ def aioredis1_hash(
miss_value=None,
expire_default=expire,
coder=coder,
**kwargs
**kwargs,
)


Expand All @@ -783,7 +782,7 @@ def aioredis2(
coder=None,
user_interface=(CacheUserInterface, BulkInterfaceMixin),
storage_class=Aioredis2Storage,
**kwargs
**kwargs,
):
"""Redis interface for :mod:`asyncio`.

Expand Down Expand Up @@ -841,7 +840,7 @@ def aioredis2(
miss_value=None,
expire_default=expire,
coder=coder,
**kwargs
**kwargs,
)


Expand All @@ -852,7 +851,7 @@ def aioredis2_hash(
coder=None,
user_interface=(CacheUserInterface, BulkInterfaceMixin),
storage_class=Aioredis2HashStorage,
**kwargs
**kwargs,
):
"""Redis interface for :mod:`asyncio`.

Expand Down Expand Up @@ -905,7 +904,7 @@ def aioredis2_hash(
miss_value=None,
expire_default=expire,
coder=coder,
**kwargs
**kwargs,
)


Expand Down
7 changes: 4 additions & 3 deletions ring/func/base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
""":mod:`ring.func.base` --- The building blocks of **ring.func.\***.
""":mod:`ring.func.base` --- The building blocks of **ring.func.* **.
=====================================================================

""" # noqa: W605

import abc
import collections
import types
Expand Down Expand Up @@ -213,7 +214,7 @@ def coerce_function(t):
if issubclass(t, (list, tuple)):
return _coerce_list_and_tuple

if t == type:
if t is type:
return _coerce_type

if issubclass(t, dict):
Expand Down Expand Up @@ -269,7 +270,7 @@ def interface_attrs(**kwargs):
if "transform_args" in kwargs:
transform_args = kwargs.pop("transform_args")
if transform_args:
if type(transform_args) != tuple:
if type(transform_args) is not tuple:
transform_args = transform_args, {}
func, rules = transform_args
assert frozenset(rules.keys()) <= frozenset({"prefix_count"})
Expand Down
Loading
Loading