From ce9a10ac7924aea41c9e2f23a6d92b9bd6ef8131 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 13 Jul 2024 11:44:13 +0200 Subject: [PATCH] build(deps-dev): bump ruff from 0.5.0 to 0.5.1 (#183) * 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](https://github.com/astral-sh/ruff/compare/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] * 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] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: F-G Fernandez <26927750+frgfm@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- poetry.lock | 55 ++++++++++++++++---------- pyproject.toml | 7 ++-- src/app/crud/base.py | 10 ++--- src/app/db.py | 4 +- src/tests/conftest.py | 2 +- src/tests/endpoints/test_code.py | 2 +- src/tests/endpoints/test_guidelines.py | 10 ++--- src/tests/endpoints/test_login.py | 8 ++-- src/tests/endpoints/test_repos.py | 8 ++-- src/tests/endpoints/test_users.py | 10 ++--- 11 files changed, 67 insertions(+), 51 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c791ac0..26b6388 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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: diff --git a/poetry.lock b/poetry.lock index 7e0b7a7..d0d2c96 100644 --- a/poetry.lock +++ b/poetry.lock @@ -2471,29 +2471,29 @@ files = [ [[package]] name = "ruff" -version = "0.5.0" +version = "0.5.1" description = "An extremely fast Python linter and code formatter, written in Rust." optional = false python-versions = ">=3.7" files = [ - {file = "ruff-0.5.0-py3-none-linux_armv6l.whl", hash = "sha256:ee770ea8ab38918f34e7560a597cc0a8c9a193aaa01bfbd879ef43cb06bd9c4c"}, - {file = "ruff-0.5.0-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:38f3b8327b3cb43474559d435f5fa65dacf723351c159ed0dc567f7ab735d1b6"}, - {file = "ruff-0.5.0-py3-none-macosx_11_0_arm64.whl", hash = "sha256:7594f8df5404a5c5c8f64b8311169879f6cf42142da644c7e0ba3c3f14130370"}, - {file = "ruff-0.5.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:adc7012d6ec85032bc4e9065110df205752d64010bed5f958d25dbee9ce35de3"}, - {file = "ruff-0.5.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:d505fb93b0fabef974b168d9b27c3960714d2ecda24b6ffa6a87ac432905ea38"}, - {file = "ruff-0.5.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:9dc5cfd3558f14513ed0d5b70ce531e28ea81a8a3b1b07f0f48421a3d9e7d80a"}, - {file = "ruff-0.5.0-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:db3ca35265de239a1176d56a464b51557fce41095c37d6c406e658cf80bbb362"}, - {file = "ruff-0.5.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:b1a321c4f68809fddd9b282fab6a8d8db796b270fff44722589a8b946925a2a8"}, - {file = "ruff-0.5.0-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:2c4dfcd8d34b143916994b3876b63d53f56724c03f8c1a33a253b7b1e6bf2a7d"}, - {file = "ruff-0.5.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:81e5facfc9f4a674c6a78c64d38becfbd5e4f739c31fcd9ce44c849f1fad9e4c"}, - {file = "ruff-0.5.0-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:e589e27971c2a3efff3fadafb16e5aef7ff93250f0134ec4b52052b673cf988d"}, - {file = "ruff-0.5.0-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:d2ffbc3715a52b037bcb0f6ff524a9367f642cdc5817944f6af5479bbb2eb50e"}, - {file = "ruff-0.5.0-py3-none-musllinux_1_2_i686.whl", hash = "sha256:cd096e23c6a4f9c819525a437fa0a99d1c67a1b6bb30948d46f33afbc53596cf"}, - {file = "ruff-0.5.0-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:46e193b36f2255729ad34a49c9a997d506e58f08555366b2108783b3064a0e1e"}, - {file = "ruff-0.5.0-py3-none-win32.whl", hash = "sha256:49141d267100f5ceff541b4e06552e98527870eafa1acc9dec9139c9ec5af64c"}, - {file = "ruff-0.5.0-py3-none-win_amd64.whl", hash = "sha256:e9118f60091047444c1b90952736ee7b1792910cab56e9b9a9ac20af94cd0440"}, - {file = "ruff-0.5.0-py3-none-win_arm64.whl", hash = "sha256:ed5c4df5c1fb4518abcb57725b576659542bdbe93366f4f329e8f398c4b71178"}, - {file = "ruff-0.5.0.tar.gz", hash = "sha256:eb641b5873492cf9bd45bc9c5ae5320648218e04386a5f0c264ad6ccce8226a1"}, + {file = "ruff-0.5.1-py3-none-linux_armv6l.whl", hash = "sha256:6ecf968fcf94d942d42b700af18ede94b07521bd188aaf2cd7bc898dd8cb63b6"}, + {file = "ruff-0.5.1-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:204fb0a472f00f2e6280a7c8c7c066e11e20e23a37557d63045bf27a616ba61c"}, + {file = "ruff-0.5.1-py3-none-macosx_11_0_arm64.whl", hash = "sha256:d235968460e8758d1e1297e1de59a38d94102f60cafb4d5382033c324404ee9d"}, + {file = "ruff-0.5.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:38beace10b8d5f9b6bdc91619310af6d63dd2019f3fb2d17a2da26360d7962fa"}, + {file = "ruff-0.5.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:5e478d2f09cf06add143cf8c4540ef77b6599191e0c50ed976582f06e588c994"}, + {file = "ruff-0.5.1-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f0368d765eec8247b8550251c49ebb20554cc4e812f383ff9f5bf0d5d94190b0"}, + {file = "ruff-0.5.1-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:3a9a9a1b582e37669b0138b7c1d9d60b9edac880b80eb2baba6d0e566bdeca4d"}, + {file = "ruff-0.5.1-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:bdd9f723e16003623423affabcc0a807a66552ee6a29f90eddad87a40c750b78"}, + {file = "ruff-0.5.1-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:be9fd62c1e99539da05fcdc1e90d20f74aec1b7a1613463ed77870057cd6bd96"}, + {file = "ruff-0.5.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e216fc75a80ea1fbd96af94a6233d90190d5b65cc3d5dfacf2bd48c3e067d3e1"}, + {file = "ruff-0.5.1-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:c4c2112e9883a40967827d5c24803525145e7dab315497fae149764979ac7929"}, + {file = "ruff-0.5.1-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:dfaf11c8a116394da3b65cd4b36de30d8552fa45b8119b9ef5ca6638ab964fa3"}, + {file = "ruff-0.5.1-py3-none-musllinux_1_2_i686.whl", hash = "sha256:d7ceb9b2fe700ee09a0c6b192c5ef03c56eb82a0514218d8ff700f6ade004108"}, + {file = "ruff-0.5.1-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:bac6288e82f6296f82ed5285f597713acb2a6ae26618ffc6b429c597b392535c"}, + {file = "ruff-0.5.1-py3-none-win32.whl", hash = "sha256:5c441d9c24ec09e1cb190a04535c5379b36b73c4bc20aa180c54812c27d1cca4"}, + {file = "ruff-0.5.1-py3-none-win_amd64.whl", hash = "sha256:b1789bf2cd3d1b5a7d38397cac1398ddf3ad7f73f4de01b1e913e2abc7dfc51d"}, + {file = "ruff-0.5.1-py3-none-win_arm64.whl", hash = "sha256:2875b7596a740cbbd492f32d24be73e545a4ce0a3daf51e4f4e609962bfd3cd2"}, + {file = "ruff-0.5.1.tar.gz", hash = "sha256:3164488aebd89b1745b47fd00604fb4358d774465f20d1fcd907f9c0fc1b0655"}, ] [[package]] @@ -2693,6 +2693,21 @@ postgresql-psycopgbinary = ["psycopg[binary] (>=3.0.7)"] pymysql = ["pymysql"] sqlcipher = ["sqlcipher3_binary"] +[[package]] +name = "sqlalchemy-stubs" +version = "0.4" +description = "SQLAlchemy stubs and mypy plugin" +optional = false +python-versions = "*" +files = [ + {file = "sqlalchemy-stubs-0.4.tar.gz", hash = "sha256:c665d6dd4482ef642f01027fa06c3d5e91befabb219dc71fc2a09e7d7695f7ae"}, + {file = "sqlalchemy_stubs-0.4-py3-none-any.whl", hash = "sha256:5eec7aa110adf9b957b631799a72fef396b23ff99fe296df726645d01e312aa5"}, +] + +[package.dependencies] +mypy = ">=0.790" +typing-extensions = ">=3.7.4" + [[package]] name = "sqlmodel" version = "0.0.16" @@ -3051,4 +3066,4 @@ test = ["big-O", "jaraco.functools", "jaraco.itertools", "jaraco.test", "more-it [metadata] lock-version = "2.0" python-versions = "^3.9" -content-hash = "f485766a71c2bc76004c9ba469c6afb3259d2d3285ade1964d5c22a00192a4b4" +content-hash = "5a4786e1ca09be25247e88633bbd0d69c1d8a109316d22c328fab3c8bbabf149" diff --git a/pyproject.toml b/pyproject.toml index 248f365..8223b24 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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] @@ -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"] diff --git a/src/app/crud/base.py b/src/app/crud/base.py index 185fc96..de8ffb2 100644 --- a/src/app/crud/base.py +++ b/src/app/crud/base.py @@ -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, @@ -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: @@ -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)) @@ -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() diff --git a/src/app/db.py b/src/app/db.py index 96cfe8c..a233c7a 100644 --- a/src/app/db.py +++ b/src/app/db.py @@ -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 @@ -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: diff --git a/src/tests/conftest.py b/src/tests/conftest.py index bb82913..65554ed 100644 --- a/src/tests/conftest.py +++ b/src/tests/conftest.py @@ -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 diff --git a/src/tests/endpoints/test_code.py b/src/tests/endpoints/test_code.py index 06dbbd0..6ab0348 100644 --- a/src/tests/endpoints/test_code.py +++ b/src/tests/endpoints/test_code.py @@ -56,7 +56,7 @@ ), ], ) -@pytest.mark.asyncio() +@pytest.mark.asyncio async def test_chat( async_client: AsyncClient, guideline_session: AsyncSession, diff --git a/src/tests/endpoints/test_guidelines.py b/src/tests/endpoints/test_guidelines.py index ea067e6..c0d7774 100644 --- a/src/tests/endpoints/test_guidelines.py +++ b/src/tests/endpoints/test_guidelines.py @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, diff --git a/src/tests/endpoints/test_login.py b/src/tests/endpoints/test_login.py index 9e1f2f8..533f873 100644 --- a/src/tests/endpoints/test_login.py +++ b/src/tests/endpoints/test_login.py @@ -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, @@ -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, @@ -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, @@ -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, diff --git a/src/tests/endpoints/test_repos.py b/src/tests/endpoints/test_repos.py index 3b63d6b..ee418bb 100644 --- a/src/tests/endpoints/test_repos.py +++ b/src/tests/endpoints/test_repos.py @@ -32,7 +32,7 @@ ), ], ) -@pytest.mark.asyncio() +@pytest.mark.asyncio async def test_create_repo( async_client: AsyncClient, repo_session: AsyncSession, @@ -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, @@ -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, @@ -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, diff --git a/src/tests/endpoints/test_users.py b/src/tests/endpoints/test_users.py index 9a04790..f95782e 100644 --- a/src/tests/endpoints/test_users.py +++ b/src/tests/endpoints/test_users.py @@ -43,7 +43,7 @@ ), ], ) -@pytest.mark.asyncio() +@pytest.mark.asyncio async def test_create_user( async_client: AsyncClient, user_session: AsyncSession, @@ -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, @@ -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, @@ -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, @@ -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,