Skip to content

Commit

Permalink
build(deps-dev): bump ruff from 0.5.0 to 0.5.1 (#183)
Browse files Browse the repository at this point in the history
* build(deps-dev): bump ruff from 0.5.0 to 0.5.1

Bumps [ruff](https://github.com/astral-sh/ruff) from 0.5.0 to 0.5.1.
- [Release notes](https://github.com/astral-sh/ruff/releases)
- [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md)
- [Commits](astral-sh/ruff@0.5.0...0.5.1)

---
updated-dependencies:
- dependency-name: ruff
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

* style(pre-commit): bump ruff to 0.5.1

* style(tests): fix lint

* style(mypy): fix mypy warnings

* build(deps-dev): add sqlalchemy stubs

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: F-G Fernandez <[email protected]>
  • Loading branch information
dependabot[bot] and frgfm committed Jul 13, 2024
1 parent a97ce03 commit ce9a10a
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 51 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ repos:
- id: debug-statements
language_version: python3
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.5.0'
rev: 'v0.5.1'
hooks:
- id: ruff
args:
Expand Down
55 changes: 35 additions & 20 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@ httptools = "^0.6.1"
optional = true

[tool.poetry.group.quality.dependencies]
ruff = "==0.5.0"
ruff = "==0.5.1"
mypy = "==1.10.0"
types-requests = ">=2.0.0"
types-urllib3 = ">=1.26.25"
types-passlib = ">=1.7.0"
sqlalchemy-stubs = "^0.4"
pre-commit = "^3.6.0"

[tool.poetry.group.demo]
Expand Down Expand Up @@ -135,9 +136,9 @@ known-third-party = ["fastapi"]

[tool.ruff.lint.per-file-ignores]
"**/__init__.py" = ["I001", "F401", "CPY001"]
"scripts/**.py" = ["D", "T201", "S101", "ANN"]
"scripts/**.py" = ["D", "T201", "S101", "ANN", "RUF030"]
".github/**.py" = ["D", "T201", "ANN"]
"src/tests/**.py" = ["D103", "CPY001", "S101", "T201", "ANN001", "ANN201", "ARG001"]
"src/tests/**.py" = ["D103", "CPY001", "S101", "T201", "ANN001", "ANN201", "ARG001", "RUF030"]
"src/migrations/versions/**.py" = ["CPY001"]
"src/migrations/**.py" = ["ANN"]
"client/tests/**.py" = ["D103", "CPY001", "S101"]
Expand Down
10 changes: 5 additions & 5 deletions src/app/crud/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async def create(self, payload: CreateSchemaType) -> ModelType:
return entry

async def get(self, entry_id: int, strict: bool = False) -> Union[ModelType, None]:
entry = await self.session.get(self.model, entry_id)
entry: Union[ModelType, None] = await self.session.get(self.model, entry_id)
if strict and entry is None:
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND,
Expand All @@ -48,7 +48,7 @@ async def get(self, entry_id: int, strict: bool = False) -> Union[ModelType, Non
return entry

async def get_by(self, field_name: str, val: Union[str, int], strict: bool = False) -> Union[ModelType, None]:
statement = select(self.model).where(getattr(self.model, field_name) == val)
statement = select(self.model).where(getattr(self.model, field_name) == val) # type: ignore[var-annotated]
results = await self.session.exec(statement=statement)
entry = results.one_or_none()
if strict and entry is None:
Expand All @@ -59,10 +59,10 @@ async def get_by(self, field_name: str, val: Union[str, int], strict: bool = Fal
return entry

async def fetch_all(self, filter_pair: Union[Tuple[str, Any], None] = None) -> List[ModelType]:
statement = select(self.model)
statement = select(self.model) # type: ignore[var-annotated]
if isinstance(filter_pair, tuple):
statement = statement.where(getattr(self.model, filter_pair[0]) == filter_pair[1])
return await self.session.exec(statement=statement) # type: ignore[return-value]
return await self.session.exec(statement=statement)

async def update(self, entry_id: int, payload: UpdateSchemaType) -> ModelType:
access = cast(ModelType, await self.get(entry_id, strict=True))
Expand All @@ -79,7 +79,7 @@ async def update(self, entry_id: int, payload: UpdateSchemaType) -> ModelType:

async def delete(self, entry_id: int) -> None:
await self.get(entry_id, strict=True)
statement = delete(self.model).where(self.model.id == entry_id) # type: ignore[attr-defined]
statement = delete(self.model).where(self.model.id == entry_id)

await self.session.exec(statement=statement) # type: ignore[call-overload]
await self.session.commit()
4 changes: 2 additions & 2 deletions src/app/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@


async def get_session() -> AsyncSession: # type: ignore[misc]
async_session = sessionmaker(bind=engine, class_=AsyncSession, expire_on_commit=False) # type: ignore[call-overload]
async_session = sessionmaker(bind=engine, class_=AsyncSession, expire_on_commit=False)
async with async_session() as session:
yield session

Expand All @@ -34,7 +34,7 @@ async def init_db() -> None:

async with AsyncSession(engine) as session:
# Check if admin exists
statement = select(User).where(User.login == settings.SUPERADMIN_LOGIN)
statement = select(User).where(User.login == settings.SUPERADMIN_LOGIN) # type: ignore[var-annotated]
results = await session.exec(statement=statement)
user = results.one_or_none()
if not user:
Expand Down
2 changes: 1 addition & 1 deletion src/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def event_loop(request) -> Generator:

@pytest_asyncio.fixture(scope="function")
async def async_client() -> AsyncGenerator[AsyncClient, None]:
async with AsyncClient(
async with AsyncClient( # noqa: S113
app=app, base_url=f"http://api.localhost:8050{settings.API_V1_STR}", follow_redirects=True
) as client:
yield client
Expand Down
2 changes: 1 addition & 1 deletion src/tests/endpoints/test_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
),
],
)
@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_chat(
async_client: AsyncClient,
guideline_session: AsyncSession,
Expand Down
10 changes: 5 additions & 5 deletions src/tests/endpoints/test_guidelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
(1, {"content": "Quacky quack"}, 201, None),
],
)
@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_create_guideline(
async_client: AsyncClient,
guideline_session: AsyncSession,
Expand Down Expand Up @@ -50,7 +50,7 @@ async def test_create_guideline(
(1, 2, 200, None, 1),
],
)
@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_get_guideline(
async_client: AsyncClient,
guideline_session: AsyncSession,
Expand Down Expand Up @@ -80,7 +80,7 @@ async def test_get_guideline(
(1, 200, None, pytest.guideline_table[1:]),
],
)
@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_fetch_guidelines(
async_client: AsyncClient,
guideline_session: AsyncSession,
Expand Down Expand Up @@ -113,7 +113,7 @@ async def test_fetch_guidelines(
(1, 2, 200, None),
],
)
@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_delete_guideline(
async_client: AsyncClient,
guideline_session: AsyncSession,
Expand Down Expand Up @@ -146,7 +146,7 @@ async def test_delete_guideline(
(1, 2, {"content": "New guideline details"}, 200, None, 1),
],
)
@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_update_guideline_content(
async_client: AsyncClient,
guideline_session: AsyncSession,
Expand Down
8 changes: 4 additions & 4 deletions src/tests/endpoints/test_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
({"github_token": "foo"}, 401, "Bad credentials"),
],
)
@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_login_with_github_token(
async_client: AsyncClient,
user_session: AsyncSession,
Expand All @@ -36,7 +36,7 @@ async def test_login_with_github_token(
({"username": "first_login", "password": "first_pwd"}, 200, None),
],
)
@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_login_with_creds(
async_client: AsyncClient,
user_session: AsyncSession,
Expand Down Expand Up @@ -64,7 +64,7 @@ async def test_login_with_creds(
({"code": "foo", "redirect_uri": "https://quackai.com"}, 404, None, None),
],
)
@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_request_github_token_from_code(
async_client: AsyncClient,
user_session: AsyncSession,
Expand All @@ -87,7 +87,7 @@ async def test_request_github_token_from_code(
("read:user%20user:email%20repo", "https://app.quackai.com", 307),
],
)
@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_authorize_github(
async_client: AsyncClient,
user_session: AsyncSession,
Expand Down
8 changes: 4 additions & 4 deletions src/tests/endpoints/test_repos.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
),
],
)
@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_create_repo(
async_client: AsyncClient,
repo_session: AsyncSession,
Expand Down Expand Up @@ -64,7 +64,7 @@ async def test_create_repo(
(1, 1, 200, None, 0),
],
)
@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_get_repo(
async_client: AsyncClient,
repo_session: AsyncSession,
Expand Down Expand Up @@ -94,7 +94,7 @@ async def test_get_repo(
(1, 403, "Incompatible token scope.", None),
],
)
@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_fetch_repos(
async_client: AsyncClient,
repo_session: AsyncSession,
Expand Down Expand Up @@ -127,7 +127,7 @@ async def test_fetch_repos(
(1, 2, 403, "Incompatible token scope."),
],
)
@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_delete_repo(
async_client: AsyncClient,
repo_session: AsyncSession,
Expand Down
10 changes: 5 additions & 5 deletions src/tests/endpoints/test_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
),
],
)
@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_create_user(
async_client: AsyncClient,
user_session: AsyncSession,
Expand Down Expand Up @@ -81,7 +81,7 @@ async def test_create_user(
(0, 2, 200, None, 1),
],
)
@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_get_user(
async_client: AsyncClient,
user_session: AsyncSession,
Expand Down Expand Up @@ -111,7 +111,7 @@ async def test_get_user(
(1, 403, "Incompatible token scope."),
],
)
@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_fetch_users(
async_client: AsyncClient,
user_session: AsyncSession,
Expand Down Expand Up @@ -141,7 +141,7 @@ async def test_fetch_users(
(1, 2, 403, "Incompatible token scope."),
],
)
@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_delete_user(
async_client: AsyncClient,
user_session: AsyncSession,
Expand Down Expand Up @@ -173,7 +173,7 @@ async def test_delete_user(
(1, 2, {"password": "HeyQuack!"}, 403, "Incompatible token scope.", None),
],
)
@pytest.mark.asyncio()
@pytest.mark.asyncio
async def test_update_user_password(
async_client: AsyncClient,
user_session: AsyncSession,
Expand Down

0 comments on commit ce9a10a

Please sign in to comment.