⬆️ 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: end-of-file-fixer
- id: trailing-whitespace - id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit - repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.0 rev: v0.4.7
hooks: hooks:
- id: ruff - id: ruff
args: args:

View File

@ -1,2 +1,2 @@
# For mkdocstrings and code generator using templates # 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 # For image processing by Material for MkDocs
cairosvg==2.7.0 cairosvg==2.7.0
mkdocstrings[python]==0.23.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 # For griffe, it formats with black
black==23.3.0
typer == 0.12.3 typer == 0.12.3

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -56,8 +56,7 @@ _T{{ i }} = TypeVar("_T{{ i }}")
# Generated TypeVars end # Generated TypeVars end
@overload @overload
def select(__ent0: _TCCA[_T0]) -> SelectOfScalar[_T0]: def select(__ent0: _TCCA[_T0]) -> SelectOfScalar[_T0]: ...
...
@overload @overload
@ -72,8 +71,7 @@ def select(__ent0: _TScalar_0) -> SelectOfScalar[_TScalar_0]: # type: ignore
@overload @overload
def select( # type: ignore def select( # type: ignore
{% for arg in signature[0] %}{{ arg.name }}: {{ arg.annotation }}, {% endfor %} {% 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 %} {% 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)