Skip to content

Commit 3216506

Browse files
authored
ci: use ruff instead of isort and flake8 (#34)
1 parent a55dc7f commit 3216506

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1063
-1034
lines changed

.circleci/config.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Taken from: https://jacobian.org/til/github-actions-poetry/
2+
on: push
3+
4+
jobs:
5+
test:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/checkout@v2
9+
- uses: actions/setup-python@v2
10+
with:
11+
python-version: 3.11
12+
13+
- name: cache poetry install
14+
uses: actions/cache@v2
15+
with:
16+
path: ~/.local
17+
key: poetry-1.1.9-0
18+
19+
- uses: snok/install-poetry@v1
20+
with:
21+
version: 1.1.9
22+
virtualenvs-create: true
23+
virtualenvs-in-project: true
24+
25+
- name: cache deps
26+
id: cache-deps
27+
uses: actions/cache@v2
28+
with:
29+
path: .venv
30+
key: pydeps-${{ hashFiles('**/poetry.lock') }}
31+
32+
# Install dependencies. `--no-root` means "install all dependencies but not the project
33+
# itself", which is what you want to avoid caching _your_ code. The `if` statement
34+
# ensures this only runs on a cache miss.
35+
- run: poetry install --no-interaction --no-root
36+
if: steps.cache-deps.outputs.cache-hit != 'true'
37+
38+
- name: Use Node.js
39+
uses: actions/setup-node@v3
40+
with:
41+
node-version-file: "package.json"
42+
cache: "yarn"
43+
44+
- run: yarn install --frozen-lockfile --non-interactive
45+
46+
# Now install _your_ project. This isn't necessary for many types of projects -- particularly
47+
# things like Django apps don't need this. But it's a good idea since it fully-exercises the
48+
# pyproject.toml and makes that if you add things like console-scripts at some point that
49+
# they'll be installed and working.
50+
- run: poetry install --no-interaction
51+
52+
- name: lint
53+
run: ./s/lint
54+

coreapi-stubs/compat.pyi

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
from typing import Union
2-
3-
def force_bytes(string: Union[str, bytes]) -> bytes: ...
4-
def force_text(string: Union[str, bytes]) -> str: ...
1+
def force_bytes(string: str | bytes) -> bytes: ...
2+
def force_text(string: str | bytes) -> str: ...

coreschema-stubs/compat.pyi

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
from typing import Tuple, Type, Union
1+
def force_bytes(string: str | bytes) -> bytes: ...
2+
def force_text(string: str | bytes) -> str: ...
23

3-
def force_bytes(string: Union[str, bytes]) -> bytes: ...
4-
def force_text(string: Union[str, bytes]) -> str: ...
5-
6-
text_types: Tuple[Type[str]]
7-
numeric_types: Tuple[Type[float], Type[int]]
4+
text_types: tuple[type[str]]
5+
numeric_types: tuple[type[float], type[int]]

coreschema-stubs/schemas.pyi

Lines changed: 55 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from typing import Any, List, NamedTuple, Optional, Pattern
1+
from re import Pattern
2+
from typing import Any, NamedTuple
23

34
from coreschema.compat import numeric_types as numeric_types
45
from coreschema.compat import text_types as text_types
@@ -7,16 +8,16 @@ from coreschema.utils import uniq as uniq
78

89
class Error(NamedTuple):
910
text: str
10-
index: List[str] # type: ignore [assignment]
11+
index: list[str] # type: ignore [assignment]
1112

12-
def push_index(errors: List[Error], key: Any) -> List[str]: ...
13+
def push_index(errors: list[Error], key: Any) -> list[str]: ...
1314

1415
class Schema:
15-
errors: List[Error] = ...
16+
errors: list[Error] = ...
1617
title: Any = ...
1718
description: Any = ...
1819
default: Any = ...
19-
def __init__(self, title: str = ..., description: str = ..., default: Optional[Any] = ...) -> None: ...
20+
def __init__(self, title: str = ..., description: str = ..., default: Any | None = ...) -> None: ...
2021
def make_error(self, code: str) -> Error: ...
2122
def __or__(self, other: Schema) -> Union: ...
2223
def __and__(self, other: Schema) -> Intersection: ...
@@ -25,137 +26,137 @@ class Schema:
2526
def __eq__(self, other: Schema) -> bool: ... # type: ignore [override]
2627

2728
class Object(Schema):
28-
errors: List[Error] = ...
29+
errors: list[Error] = ...
2930
additional_properties_schema: Any = ...
3031
properties: Any = ...
31-
required: Optional[bool] = ...
32+
required: bool | None = ...
3233
max_properties: int = ...
3334
min_properties: int = ...
3435
pattern_properties: Any = ...
3536
additional_properties: Any = ...
3637
pattern_properties_regex: Any = ...
3738
def __init__(
3839
self,
39-
properties: Optional[Any] = ...,
40-
required: Optional[bool] = ...,
41-
max_properties: Optional[Any] = ...,
42-
min_properties: Optional[Any] = ...,
43-
pattern_properties: Optional[Any] = ...,
40+
properties: Any | None = ...,
41+
required: bool | None = ...,
42+
max_properties: Any | None = ...,
43+
min_properties: Any | None = ...,
44+
pattern_properties: Any | None = ...,
4445
additional_properties: bool = ...,
4546
**kwargs: Any
4647
) -> None: ...
47-
def validate(self, value: Any, context: Optional[Any] = ...) -> List[Error]: ...
48+
def validate(self, value: Any, context: Any | None = ...) -> list[Error]: ...
4849

4950
class Array(Schema):
50-
errors: List[Error] = ...
51+
errors: list[Error] = ...
5152
items: Schema = ...
5253
max_items: int = ...
5354
min_items: int = ...
5455
unique_items: int = ...
5556
additional_items: int = ...
5657
def __init__(
5758
self,
58-
items: Optional[Any] = ...,
59-
max_items: Optional[Any] = ...,
60-
min_items: Optional[Any] = ...,
59+
items: Any | None = ...,
60+
max_items: Any | None = ...,
61+
min_items: Any | None = ...,
6162
unique_items: bool = ...,
6263
additional_items: bool = ...,
6364
**kwargs: Any
6465
) -> None: ...
65-
def validate(self, value: Any, context: Optional[Any] = ...) -> List[Error]: ...
66+
def validate(self, value: Any, context: Any | None = ...) -> list[Error]: ...
6667

6768
class Number(Schema):
6869
integer_only: bool = ...
69-
errors: List[Error] = ...
70+
errors: list[Error] = ...
7071
minimum: int = ...
7172
maximum: int = ...
7273
exclusive_minimum: int = ...
7374
exclusive_maximum: int = ...
74-
multiple_of: Optional[int] = ...
75+
multiple_of: int | None = ...
7576
def __init__(
7677
self,
77-
minimum: Optional[int] = ...,
78-
maximum: Optional[int] = ...,
78+
minimum: int | None = ...,
79+
maximum: int | None = ...,
7980
exclusive_minimum: bool = ...,
8081
exclusive_maximum: bool = ...,
81-
multiple_of: Optional[int] = ...,
82+
multiple_of: int | None = ...,
8283
**kwargs: Any
8384
) -> None: ...
84-
def validate(self, value: Any, context: Optional[Any] = ...) -> List[Error]: ...
85+
def validate(self, value: Any, context: Any | None = ...) -> list[Error]: ...
8586

8687
class Integer(Number):
87-
errors: List[Error] = ...
88+
errors: list[Error] = ...
8889
integer_only: bool = ...
8990

9091
class String(Schema):
91-
errors: List[Error] = ...
92+
errors: list[Error] = ...
9293
max_length: Any = ...
9394
min_length: Any = ...
9495
pattern: str = ...
9596
format: str = ...
9697
pattern_regex: Pattern[str] = ...
9798
def __init__(
9899
self,
99-
max_length: Optional[int] = ...,
100-
min_length: Optional[int] = ...,
101-
pattern: Optional[str] = ...,
102-
format: Optional[Any] = ...,
100+
max_length: int | None = ...,
101+
min_length: int | None = ...,
102+
pattern: str | None = ...,
103+
format: Any | None = ...,
103104
**kwargs: Any
104105
) -> None: ...
105-
def validate(self, value: Any, context: Optional[Any] = ...) -> List[Error]: ...
106+
def validate(self, value: Any, context: Any | None = ...) -> list[Error]: ...
106107

107108
class Boolean(Schema):
108-
errors: List[Error] = ...
109-
def validate(self, value: Any, context: Optional[Any] = ...) -> List[Error]: ...
109+
errors: list[Error] = ...
110+
def validate(self, value: Any, context: Any | None = ...) -> list[Error]: ...
110111

111112
class Null(Schema):
112-
errors: List[Error] = ...
113-
def validate(self, value: Any, context: Optional[Any] = ...) -> List[Error]: ...
113+
errors: list[Error] = ...
114+
def validate(self, value: Any, context: Any | None = ...) -> list[Error]: ...
114115

115116
class Enum(Schema):
116-
errors: List[Error] = ...
117+
errors: list[Error] = ...
117118
enum: Any = ...
118119
exact: Any = ...
119120
def __init__(self, enum: Any, **kwargs: Any) -> None: ...
120-
def validate(self, value: Any, context: Optional[Any] = ...) -> List[Error]: ...
121+
def validate(self, value: Any, context: Any | None = ...) -> list[Error]: ...
121122

122123
class Anything(Schema):
123-
errors: List[Error] = ...
124+
errors: list[Error] = ...
124125
types: Any = ...
125-
def validate(self, value: Any, context: Optional[Any] = ...) -> List[Error]: ...
126+
def validate(self, value: Any, context: Any | None = ...) -> list[Error]: ...
126127

127128
class Union(Schema):
128-
errors: List[Error] = ...
129-
children: List[Schema] = ...
130-
def __init__(self, children: List[Schema], **kwargs: Any) -> None: ...
131-
def validate(self, value: Any, context: Optional[Any] = ...) -> List[Error]: ...
129+
errors: list[Error] = ...
130+
children: list[Schema] = ...
131+
def __init__(self, children: list[Schema], **kwargs: Any) -> None: ...
132+
def validate(self, value: Any, context: Any | None = ...) -> list[Error]: ...
132133

133134
class Intersection(Schema):
134-
children: List[Schema] = ...
135-
def __init__(self, children: List[Schema], **kwargs: Any) -> None: ...
136-
def validate(self, value: Any, context: Optional[Any] = ...) -> List[Error]: ...
135+
children: list[Schema] = ...
136+
def __init__(self, children: list[Schema], **kwargs: Any) -> None: ...
137+
def validate(self, value: Any, context: Any | None = ...) -> list[Error]: ...
137138

138139
class ExclusiveUnion(Schema):
139-
errors: List[Error] = ...
140-
children: List[Schema] = ...
141-
def __init__(self, children: List[Schema], **kwargs: Any) -> None: ...
142-
def validate(self, value: Any, context: Optional[Any] = ...) -> List[Error]: ...
140+
errors: list[Error] = ...
141+
children: list[Schema] = ...
142+
def __init__(self, children: list[Schema], **kwargs: Any) -> None: ...
143+
def validate(self, value: Any, context: Any | None = ...) -> list[Error]: ...
143144

144145
class Not(Schema):
145-
errors: List[Error] = ...
146+
errors: list[Error] = ...
146147
child: Any = ...
147148
def __init__(self, child: Any, **kwargs: Any) -> None: ...
148-
def validate(self, value: Any, context: Optional[Any] = ...) -> List[Error]: ...
149+
def validate(self, value: Any, context: Any | None = ...) -> list[Error]: ...
149150

150151
class Ref(Schema):
151152
ref_name: Any = ...
152153
def __init__(self, ref_name: Any) -> None: ...
153154
def dereference(self, context: Any) -> Any: ...
154-
def validate(self, value: Any, context: Optional[Any] = ...) -> List[Error]: ...
155+
def validate(self, value: Any, context: Any | None = ...) -> list[Error]: ...
155156

156157
class RefSpace(Schema):
157158
refs: Any = ...
158159
root: Any = ...
159160
root_validator: Any = ...
160161
def __init__(self, refs: Any, root: Any) -> None: ...
161-
def validate(self, value: Any) -> List[Error]: ...
162+
def validate(self, value: Any) -> list[Error]: ...

coreschema-stubs/utils.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from typing import Any, Iterable
1+
from collections.abc import Iterable
2+
from typing import Any
23

34
def unbool(element: Any, true: Any = ..., false: Any = ...) -> Any: ...
45
def uniq(container: Iterable[object]) -> bool: ...

openapi_codec-stubs/decode.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from typing import Any, Optional
1+
from typing import Any
22

33
def dereference(lookup_string: Any, struct: Any) -> Any: ...
44
def is_json_pointer(value: Any) -> Any: ...
5-
def get_dicts(item: Any, dereference_using: Optional[Any] = ...) -> Any: ...
5+
def get_dicts(item: Any, dereference_using: Any | None = ...) -> Any: ...
66
def get_strings(item: Any) -> Any: ...

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,8 @@
77
"license": "MIT",
88
"devDependencies": {
99
"pyright": "^1.1.110"
10+
},
11+
"volta": {
12+
"node": "18.15.0"
1013
}
1114
}

poetry.lock

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)