Skip to content

Commit e723cb7

Browse files
authored
Merge pull request #204 from youknowone/format
Fix format
2 parents 99ea8a9 + 9e6c6e7 commit e723cb7

File tree

11 files changed

+56
-50
lines changed

11 files changed

+56
-50
lines changed

.github/workflows/python-package.yml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,19 @@ on:
1111

1212
jobs:
1313
build:
14+
services:
15+
redis:
16+
image: redis
17+
ports: ['6379:6379']
18+
memcached:
19+
image: memcached
20+
ports: ['11211:11211']
21+
1422
runs-on: ubuntu-latest
1523
strategy:
1624
fail-fast: false
1725
matrix:
18-
python-version: ["2.7", "3.7", "3.8", "3.9", "3.10", "3.11"]
26+
python-version: ["3.10", "3.11", "3.12"]
1927

2028
steps:
2129
- uses: actions/checkout@v2
@@ -29,19 +37,14 @@ jobs:
2937
run: |
3038
sudo apt-get install libmemcached-dev
3139
python -m pip install --upgrade pip
32-
python --version | grep '3.' && python -m pip install black
40+
python -m pip install ruff
3341
python -m pip install -e '.[tests]'
34-
- name: Lint with black
42+
- name: Lint with ruff
3543
run: |
36-
black --check ring tests setup.py
37-
if: matrix.python-version != '2.7'
38-
- name: Start containers
39-
run: docker-compose -f "docker-compose.yml" up -d --build
44+
ruff format --diff ring tests setup.py
4045
- name: Test with pytest
4146
run: |
4247
pytest
43-
- name: Stop containers
44-
run: docker-compose -f "docker-compose.yml" down
4548
4649
- name: Codecov
4750
run: bash <(curl -s https://codecov.io/bash)

ring/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
44
Common ring decorators are aliased in this level as shortcuts.
55
"""
6+
67
import ring.coder # noqa
78
from ring.__version__ import __version__ # noqa
89
from ring.func import lru, dict, shelve, disk, memcache, redis, redis_hash

ring/coder.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
Coder is a configurable layer that provides ways to encode raw data and decode
55
stored cache data.
66
"""
7+
78
import abc
89
import six
910
from collections import namedtuple
@@ -105,7 +106,7 @@ def get_or_coderize(self, raw_coder):
105106
if coder is None:
106107
if isinstance(raw_coder, str): # py2 support
107108
raise TypeError(
108-
"The given coder is not a registered name in coder " "registry."
109+
"The given coder is not a registered name in coder registry."
109110
)
110111
coder = coderize(raw_coder)
111112
return coder

ring/django.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
""":mod:`ring.django` --- Django support
22
========================================
33
"""
4+
45
from __future__ import absolute_import
56

67
import warnings
@@ -47,7 +48,7 @@ def transform_cache_page_args(wire, rules, args, kwargs):
4748
raw_request = args[0]
4849
if isinstance(raw_request, HttpRequest):
4950
request = raw_request
50-
elif type(raw_request) == tuple:
51+
elif type(raw_request) is tuple:
5152
template_request, path_hint = raw_request
5253
if not isinstance(template_request, HttpRequest):
5354
raise TypeError

ring/func/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
44
Ring object factory functions are aggregated in this module.
55
"""
6+
67
from __future__ import absolute_import
78
from ring.func import sync
89

ring/func/asyncio.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
This module includes building blocks and storage implementations of **Ring**
55
factories for :mod:`asyncio`.
66
"""
7+
78
import sys
89
from functools import wraps, partial
910

@@ -174,9 +175,7 @@ class CacheUserInterface(fbase.BaseUserInterface):
174175
details.
175176
"""
176177

177-
@fbase.interface_attrs(
178-
return_annotation=lambda a: Optional[a.get("return", Any)]
179-
) # noqa: F722
178+
@fbase.interface_attrs(return_annotation=lambda a: Optional[a.get("return", Any)]) # noqa: F722
180179
async def get(self, wire, **kwargs):
181180
key = self.key(wire, **kwargs)
182181
try:
@@ -565,7 +564,7 @@ def dict(
565564
coder=None,
566565
user_interface=CacheUserInterface,
567566
storage_class=None,
568-
**kwargs
567+
**kwargs,
569568
):
570569
""":class:`dict` interface for :mod:`asyncio`.
571570
@@ -587,7 +586,7 @@ def dict(
587586
miss_value=None,
588587
expire_default=expire,
589588
coder=coder,
590-
**kwargs
589+
**kwargs,
591590
)
592591

593592

@@ -599,7 +598,7 @@ def aiomcache(
599598
user_interface=(CacheUserInterface, BulkInterfaceMixin),
600599
storage_class=AiomcacheStorage,
601600
key_encoding="utf-8",
602-
**kwargs
601+
**kwargs,
603602
):
604603
"""Memcached_ interface for :mod:`asyncio`.
605604
@@ -639,7 +638,7 @@ def aiomcache(
639638
coder=coder,
640639
key_encoding=key_encoding,
641640
key_refactor=key_refactor,
642-
**kwargs
641+
**kwargs,
643642
)
644643

645644

@@ -650,7 +649,7 @@ def aioredis1(
650649
coder=None,
651650
user_interface=(CacheUserInterface, BulkInterfaceMixin),
652651
storage_class=Aioredis1Storage,
653-
**kwargs
652+
**kwargs,
654653
):
655654
"""Redis interface for :mod:`asyncio`.
656655
@@ -708,7 +707,7 @@ def aioredis1(
708707
miss_value=None,
709708
expire_default=expire,
710709
coder=coder,
711-
**kwargs
710+
**kwargs,
712711
)
713712

714713

@@ -719,7 +718,7 @@ def aioredis1_hash(
719718
coder=None,
720719
user_interface=(CacheUserInterface, BulkInterfaceMixin),
721720
storage_class=Aioredis1HashStorage,
722-
**kwargs
721+
**kwargs,
723722
):
724723
"""Redis interface for :mod:`asyncio`.
725724
@@ -772,7 +771,7 @@ def aioredis1_hash(
772771
miss_value=None,
773772
expire_default=expire,
774773
coder=coder,
775-
**kwargs
774+
**kwargs,
776775
)
777776

778777

@@ -783,7 +782,7 @@ def aioredis2(
783782
coder=None,
784783
user_interface=(CacheUserInterface, BulkInterfaceMixin),
785784
storage_class=Aioredis2Storage,
786-
**kwargs
785+
**kwargs,
787786
):
788787
"""Redis interface for :mod:`asyncio`.
789788
@@ -841,7 +840,7 @@ def aioredis2(
841840
miss_value=None,
842841
expire_default=expire,
843842
coder=coder,
844-
**kwargs
843+
**kwargs,
845844
)
846845

847846

@@ -852,7 +851,7 @@ def aioredis2_hash(
852851
coder=None,
853852
user_interface=(CacheUserInterface, BulkInterfaceMixin),
854853
storage_class=Aioredis2HashStorage,
855-
**kwargs
854+
**kwargs,
856855
):
857856
"""Redis interface for :mod:`asyncio`.
858857
@@ -905,7 +904,7 @@ def aioredis2_hash(
905904
miss_value=None,
906905
expire_default=expire,
907906
coder=coder,
908-
**kwargs
907+
**kwargs,
909908
)
910909

911910

ring/func/base.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
""":mod:`ring.func.base` --- The building blocks of **ring.func.\***.
1+
""":mod:`ring.func.base` --- The building blocks of **ring.func.* **.
22
=====================================================================
33
44
""" # noqa: W605
5+
56
import abc
67
import collections
78
import types
@@ -213,7 +214,7 @@ def coerce_function(t):
213214
if issubclass(t, (list, tuple)):
214215
return _coerce_list_and_tuple
215216

216-
if t == type:
217+
if t is type:
217218
return _coerce_type
218219

219220
if issubclass(t, dict):
@@ -269,7 +270,7 @@ def interface_attrs(**kwargs):
269270
if "transform_args" in kwargs:
270271
transform_args = kwargs.pop("transform_args")
271272
if transform_args:
272-
if type(transform_args) != tuple:
273+
if type(transform_args) is not tuple:
273274
transform_args = transform_args, {}
274275
func, rules = transform_args
275276
assert frozenset(rules.keys()) <= frozenset({"prefix_count"})

0 commit comments

Comments
 (0)