⬆️ Upgrade Ruff and Black (#968)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Sebastián Ramírez 2024-06-03 22:22:04 -05:00 committed by GitHub
parent e2f646dea5
commit b560e9deb8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 63 additions and 84 deletions

View File

@ -14,7 +14,7 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.0
rev: v0.4.7
hooks:
- id: ruff
args:

View File

@ -1,2 +1,2 @@
# For mkdocstrings and code generator using templates
black >=22.10,<24.0
black >=22.10

View File

@ -12,7 +12,7 @@ pillow==10.1.0
# For image processing by Material for MkDocs
cairosvg==2.7.0
mkdocstrings[python]==0.23.0
griffe-typingdoc==0.2.2
# Enable griffe-typingdoc once dropping Python 3.7 and upgrading typing-extensions
# griffe-typingdoc==0.2.5
# For griffe, it formats with black
black==23.3.0
typer == 0.12.3

View File

@ -3,7 +3,7 @@
pytest >=7.0.1,<8.0.0
coverage[toml] >=6.2,<8.0
mypy ==1.4.1
ruff ==0.2.0
ruff ==0.4.7
# For FastAPI tests
fastapi >=0.103.2
httpx ==0.24.1

View File

@ -3,7 +3,6 @@
set -e
set -x
CHECK_JINJA=1 python scripts/generate_select.py
coverage run -m pytest tests
coverage combine
coverage report --show-missing

View File

@ -43,8 +43,7 @@ class AsyncSession(_AsyncSession):
bind_arguments: Optional[Dict[str, Any]] = None,
_parent_execute_state: Optional[Any] = None,
_add_event: Optional[Any] = None,
) -> TupleResult[_TSelectParam]:
...
) -> TupleResult[_TSelectParam]: ...
@overload
async def exec(
@ -56,8 +55,7 @@ class AsyncSession(_AsyncSession):
bind_arguments: Optional[Dict[str, Any]] = None,
_parent_execute_state: Optional[Any] = None,
_add_event: Optional[Any] = None,
) -> ScalarResult[_TSelectParam]:
...
) -> ScalarResult[_TSelectParam]: ...
async def exec(
self,

View File

@ -231,8 +231,7 @@ def Field(
sa_column_args: Union[Sequence[Any], UndefinedType] = Undefined,
sa_column_kwargs: Union[Mapping[str, Any], UndefinedType] = Undefined,
schema_extra: Optional[Dict[str, Any]] = None,
) -> Any:
...
) -> Any: ...
@overload
@ -268,8 +267,7 @@ def Field(
repr: bool = True,
sa_column: Union[Column, UndefinedType] = Undefined, # type: ignore
schema_extra: Optional[Dict[str, Any]] = None,
) -> Any:
...
) -> Any: ...
def Field(
@ -361,8 +359,7 @@ def Relationship(
link_model: Optional[Any] = None,
sa_relationship_args: Optional[Sequence[Any]] = None,
sa_relationship_kwargs: Optional[Mapping[str, Any]] = None,
) -> Any:
...
) -> Any: ...
@overload
@ -371,8 +368,7 @@ def Relationship(
back_populates: Optional[str] = None,
link_model: Optional[Any] = None,
sa_relationship: Optional[RelationshipProperty[Any]] = None,
) -> Any:
...
) -> Any: ...
def Relationship(

View File

@ -35,8 +35,7 @@ class Session(_Session):
bind_arguments: Optional[Dict[str, Any]] = None,
_parent_execute_state: Optional[Any] = None,
_add_event: Optional[Any] = None,
) -> TupleResult[_TSelectParam]:
...
) -> TupleResult[_TSelectParam]: ...
@overload
def exec(
@ -48,8 +47,7 @@ class Session(_Session):
bind_arguments: Optional[Dict[str, Any]] = None,
_parent_execute_state: Optional[Any] = None,
_add_event: Optional[Any] = None,
) -> ScalarResult[_TSelectParam]:
...
) -> ScalarResult[_TSelectParam]: ...
def exec(
self,

View File

@ -111,8 +111,7 @@ _T3 = TypeVar("_T3")
@overload
def select(__ent0: _TCCA[_T0]) -> SelectOfScalar[_T0]:
...
def select(__ent0: _TCCA[_T0]) -> SelectOfScalar[_T0]: ...
@overload
@ -127,32 +126,28 @@ def select(__ent0: _TScalar_0) -> SelectOfScalar[_TScalar_0]: # type: ignore
def select( # type: ignore
__ent0: _TCCA[_T0],
__ent1: _TCCA[_T1],
) -> Select[Tuple[_T0, _T1]]:
...
) -> Select[Tuple[_T0, _T1]]: ...
@overload
def select( # type: ignore
__ent0: _TCCA[_T0],
entity_1: _TScalar_1,
) -> Select[Tuple[_T0, _TScalar_1]]:
...
) -> Select[Tuple[_T0, _TScalar_1]]: ...
@overload
def select( # type: ignore
entity_0: _TScalar_0,
__ent1: _TCCA[_T1],
) -> Select[Tuple[_TScalar_0, _T1]]:
...
) -> Select[Tuple[_TScalar_0, _T1]]: ...
@overload
def select( # type: ignore
entity_0: _TScalar_0,
entity_1: _TScalar_1,
) -> Select[Tuple[_TScalar_0, _TScalar_1]]:
...
) -> Select[Tuple[_TScalar_0, _TScalar_1]]: ...
@overload
@ -160,8 +155,7 @@ def select( # type: ignore
__ent0: _TCCA[_T0],
__ent1: _TCCA[_T1],
__ent2: _TCCA[_T2],
) -> Select[Tuple[_T0, _T1, _T2]]:
...
) -> Select[Tuple[_T0, _T1, _T2]]: ...
@overload
@ -169,8 +163,7 @@ def select( # type: ignore
__ent0: _TCCA[_T0],
__ent1: _TCCA[_T1],
entity_2: _TScalar_2,
) -> Select[Tuple[_T0, _T1, _TScalar_2]]:
...
) -> Select[Tuple[_T0, _T1, _TScalar_2]]: ...
@overload
@ -178,8 +171,7 @@ def select( # type: ignore
__ent0: _TCCA[_T0],
entity_1: _TScalar_1,
__ent2: _TCCA[_T2],
) -> Select[Tuple[_T0, _TScalar_1, _T2]]:
...
) -> Select[Tuple[_T0, _TScalar_1, _T2]]: ...
@overload
@ -187,8 +179,7 @@ def select( # type: ignore
__ent0: _TCCA[_T0],
entity_1: _TScalar_1,
entity_2: _TScalar_2,
) -> Select[Tuple[_T0, _TScalar_1, _TScalar_2]]:
...
) -> Select[Tuple[_T0, _TScalar_1, _TScalar_2]]: ...
@overload
@ -196,8 +187,7 @@ def select( # type: ignore
entity_0: _TScalar_0,
__ent1: _TCCA[_T1],
__ent2: _TCCA[_T2],
) -> Select[Tuple[_TScalar_0, _T1, _T2]]:
...
) -> Select[Tuple[_TScalar_0, _T1, _T2]]: ...
@overload
@ -205,8 +195,7 @@ def select( # type: ignore
entity_0: _TScalar_0,
__ent1: _TCCA[_T1],
entity_2: _TScalar_2,
) -> Select[Tuple[_TScalar_0, _T1, _TScalar_2]]:
...
) -> Select[Tuple[_TScalar_0, _T1, _TScalar_2]]: ...
@overload
@ -214,8 +203,7 @@ def select( # type: ignore
entity_0: _TScalar_0,
entity_1: _TScalar_1,
__ent2: _TCCA[_T2],
) -> Select[Tuple[_TScalar_0, _TScalar_1, _T2]]:
...
) -> Select[Tuple[_TScalar_0, _TScalar_1, _T2]]: ...
@overload
@ -223,8 +211,7 @@ def select( # type: ignore
entity_0: _TScalar_0,
entity_1: _TScalar_1,
entity_2: _TScalar_2,
) -> Select[Tuple[_TScalar_0, _TScalar_1, _TScalar_2]]:
...
) -> Select[Tuple[_TScalar_0, _TScalar_1, _TScalar_2]]: ...
@overload
@ -233,8 +220,7 @@ def select( # type: ignore
__ent1: _TCCA[_T1],
__ent2: _TCCA[_T2],
__ent3: _TCCA[_T3],
) -> Select[Tuple[_T0, _T1, _T2, _T3]]:
...
) -> Select[Tuple[_T0, _T1, _T2, _T3]]: ...
@overload
@ -243,8 +229,7 @@ def select( # type: ignore
__ent1: _TCCA[_T1],
__ent2: _TCCA[_T2],
entity_3: _TScalar_3,
) -> Select[Tuple[_T0, _T1, _T2, _TScalar_3]]:
...
) -> Select[Tuple[_T0, _T1, _T2, _TScalar_3]]: ...
@overload
@ -253,8 +238,7 @@ def select( # type: ignore
__ent1: _TCCA[_T1],
entity_2: _TScalar_2,
__ent3: _TCCA[_T3],
) -> Select[Tuple[_T0, _T1, _TScalar_2, _T3]]:
...
) -> Select[Tuple[_T0, _T1, _TScalar_2, _T3]]: ...
@overload
@ -263,8 +247,7 @@ def select( # type: ignore
__ent1: _TCCA[_T1],
entity_2: _TScalar_2,
entity_3: _TScalar_3,
) -> Select[Tuple[_T0, _T1, _TScalar_2, _TScalar_3]]:
...
) -> Select[Tuple[_T0, _T1, _TScalar_2, _TScalar_3]]: ...
@overload
@ -273,8 +256,7 @@ def select( # type: ignore
entity_1: _TScalar_1,
__ent2: _TCCA[_T2],
__ent3: _TCCA[_T3],
) -> Select[Tuple[_T0, _TScalar_1, _T2, _T3]]:
...
) -> Select[Tuple[_T0, _TScalar_1, _T2, _T3]]: ...
@overload
@ -283,8 +265,7 @@ def select( # type: ignore
entity_1: _TScalar_1,
__ent2: _TCCA[_T2],
entity_3: _TScalar_3,
) -> Select[Tuple[_T0, _TScalar_1, _T2, _TScalar_3]]:
...
) -> Select[Tuple[_T0, _TScalar_1, _T2, _TScalar_3]]: ...
@overload
@ -293,8 +274,7 @@ def select( # type: ignore
entity_1: _TScalar_1,
entity_2: _TScalar_2,
__ent3: _TCCA[_T3],
) -> Select[Tuple[_T0, _TScalar_1, _TScalar_2, _T3]]:
...
) -> Select[Tuple[_T0, _TScalar_1, _TScalar_2, _T3]]: ...
@overload
@ -303,8 +283,7 @@ def select( # type: ignore
entity_1: _TScalar_1,
entity_2: _TScalar_2,
entity_3: _TScalar_3,
) -> Select[Tuple[_T0, _TScalar_1, _TScalar_2, _TScalar_3]]:
...
) -> Select[Tuple[_T0, _TScalar_1, _TScalar_2, _TScalar_3]]: ...
@overload
@ -313,8 +292,7 @@ def select( # type: ignore
__ent1: _TCCA[_T1],
__ent2: _TCCA[_T2],
__ent3: _TCCA[_T3],
) -> Select[Tuple[_TScalar_0, _T1, _T2, _T3]]:
...
) -> Select[Tuple[_TScalar_0, _T1, _T2, _T3]]: ...
@overload
@ -323,8 +301,7 @@ def select( # type: ignore
__ent1: _TCCA[_T1],
__ent2: _TCCA[_T2],
entity_3: _TScalar_3,
) -> Select[Tuple[_TScalar_0, _T1, _T2, _TScalar_3]]:
...
) -> Select[Tuple[_TScalar_0, _T1, _T2, _TScalar_3]]: ...
@overload
@ -333,8 +310,7 @@ def select( # type: ignore
__ent1: _TCCA[_T1],
entity_2: _TScalar_2,
__ent3: _TCCA[_T3],
) -> Select[Tuple[_TScalar_0, _T1, _TScalar_2, _T3]]:
...
) -> Select[Tuple[_TScalar_0, _T1, _TScalar_2, _T3]]: ...
@overload
@ -343,8 +319,7 @@ def select( # type: ignore
__ent1: _TCCA[_T1],
entity_2: _TScalar_2,
entity_3: _TScalar_3,
) -> Select[Tuple[_TScalar_0, _T1, _TScalar_2, _TScalar_3]]:
...
) -> Select[Tuple[_TScalar_0, _T1, _TScalar_2, _TScalar_3]]: ...
@overload
@ -353,8 +328,7 @@ def select( # type: ignore
entity_1: _TScalar_1,
__ent2: _TCCA[_T2],
__ent3: _TCCA[_T3],
) -> Select[Tuple[_TScalar_0, _TScalar_1, _T2, _T3]]:
...
) -> Select[Tuple[_TScalar_0, _TScalar_1, _T2, _T3]]: ...
@overload
@ -363,8 +337,7 @@ def select( # type: ignore
entity_1: _TScalar_1,
__ent2: _TCCA[_T2],
entity_3: _TScalar_3,
) -> Select[Tuple[_TScalar_0, _TScalar_1, _T2, _TScalar_3]]:
...
) -> Select[Tuple[_TScalar_0, _TScalar_1, _T2, _TScalar_3]]: ...
@overload
@ -373,8 +346,7 @@ def select( # type: ignore
entity_1: _TScalar_1,
entity_2: _TScalar_2,
__ent3: _TCCA[_T3],
) -> Select[Tuple[_TScalar_0, _TScalar_1, _TScalar_2, _T3]]:
...
) -> Select[Tuple[_TScalar_0, _TScalar_1, _TScalar_2, _T3]]: ...
@overload
@ -383,8 +355,7 @@ def select( # type: ignore
entity_1: _TScalar_1,
entity_2: _TScalar_2,
entity_3: _TScalar_3,
) -> Select[Tuple[_TScalar_0, _TScalar_1, _TScalar_2, _TScalar_3]]:
...
) -> Select[Tuple[_TScalar_0, _TScalar_1, _TScalar_2, _TScalar_3]]: ...
# Generated overloads end

View File

@ -56,8 +56,7 @@ _T{{ i }} = TypeVar("_T{{ i }}")
# Generated TypeVars end
@overload
def select(__ent0: _TCCA[_T0]) -> SelectOfScalar[_T0]:
...
def select(__ent0: _TCCA[_T0]) -> SelectOfScalar[_T0]: ...
@overload
@ -72,8 +71,7 @@ def select(__ent0: _TScalar_0) -> SelectOfScalar[_TScalar_0]: # type: ignore
@overload
def select( # type: ignore
{% for arg in signature[0] %}{{ arg.name }}: {{ arg.annotation }}, {% endfor %}
) -> Select[Tuple[{%for ret in signature[1] %}{{ ret }} {% if not loop.last %}, {% endif %}{% endfor %}]]:
...
) -> Select[Tuple[{%for ret in signature[1] %}{{ ret }} {% if not loop.last %}, {% endif %}{% endfor %}]]: ...
{% endfor %}

19
tests/test_select_gen.py Normal file
View File

@ -0,0 +1,19 @@
import subprocess
import sys
from pathlib import Path
from .conftest import needs_py39
root_path = Path(__file__).parent.parent
@needs_py39
def test_select_gen() -> None:
result = subprocess.run(
[sys.executable, "scripts/generate_select.py"],
env={"CHECK_JINJA": "1"},
check=True,
cwd=root_path,
capture_output=True,
)
print(result.stdout)