Skip to content

Commit

Permalink
Fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
tarsil committed Apr 23, 2024
1 parent 1f40a9f commit c6ae175
Show file tree
Hide file tree
Showing 83 changed files with 94 additions and 134 deletions.
25 changes: 9 additions & 16 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,23 @@ repos:
args:
- --py3-plus
- --keep-runtime-typing
- repo: https://github.com/asottile/pyupgrade
rev: v2.37.3
hooks:
- id: pyupgrade
args:
- --py3-plus
- --keep-runtime-typing
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.254
rev: v0.3.0
hooks:
- id: ruff
args: ["--fix", "--line-length=99"]
- repo: https://github.com/psf/black
rev: 22.8.0
rev: 24.4.0
hooks:
- id: black
args: ["--line-length=99"]
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
name: isort (python)
args: ["--project=mongoz", "--line-length=99"]
- id: isort
name: isort (cython)
types: [cython]
args: ["--project=mongoz", "--line-length=99"]
- id: isort
name: isort (pyi)
types: [pyi]
args: ["--project=mongoz", "--line-length=99"]
ci:
autofix_commit_msg: 🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
autoupdate_commit_msg: ⬆ [pre-commit.ci] pre-commit autoupdate
16 changes: 3 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -104,19 +104,9 @@ disable_error_code = "attr-defined,arg-type,override,misc,valid-type,call-overlo
warn_unused_ignores = true
warn_redundant_casts = true

[tool.ruff]
select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
"F", # pyflakes
"C", # flake8-comprehensions
"B", # flake8-bugbear
]
ignore = [
"E501", # line too long, handled by black
"B008", # do not perform function calls in argument defaults
"C901", # too complex
]
[tool.ruff.lint]
select = ["E", "W", "F", "C", "B", "I"]
ignore = ["E501", "B008", "C901", "B026"]

exclude = ["docs_src/"]

Expand Down
5 changes: 2 additions & 3 deletions scripts/check
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export MAIN="mongoz"

set -x

${PREFIX}mypy $MAIN
${PREFIX}ruff $SOURCE_FILES --line-length 99
${PREFIX}ruff check $SOURCE_FILES --line-length 99
${PREFIX}black $SOURCE_FILES --check --diff --check --line-length 99
${PREFIX}isort $SOURCE_FILES --check --diff --project=mongoz --line-length 99
${PREFIX}mypy $MAIN
3 changes: 1 addition & 2 deletions scripts/lint
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ fi
export SOURCE_FILES="mongoz tests"
set -x

${PREFIX}ruff $SOURCE_FILES --fix --line-length 99
${PREFIX}ruff check $SOURCE_FILES --fix --line-length 99
${PREFIX}black $SOURCE_FILES --line-length 99
${PREFIX}isort $SOURCE_FILES --project=mongoz --line-length 99
${PREFIX}mypy mongoz
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import typing

import pytest
from tests.settings import TEST_DATABASE_URL

from mongoz.core.connection.registry import Registry
from tests.settings import TEST_DATABASE_URL

database_uri = TEST_DATABASE_URL
client = Registry(database_uri, event_loop=asyncio.get_running_loop)
Expand Down
1 change: 1 addition & 0 deletions tests/databases/test_database.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest

from tests.conftest import client

db = client.get_database("test_db")
Expand Down
2 changes: 1 addition & 1 deletion tests/embedded_documents/test_embedded_documents.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from typing import List

import pytest
from tests.conftest import client

import mongoz
from mongoz import Document, EmbeddedDocument
from mongoz.exceptions import InvalidKeyError
from tests.conftest import client

pytestmark = pytest.mark.anyio

Expand Down
2 changes: 1 addition & 1 deletion tests/indexes/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import typing

import pytest
from tests.settings import TEST_DATABASE_URL

from mongoz.core.connection.registry import Registry
from tests.settings import TEST_DATABASE_URL

database_uri = TEST_DATABASE_URL
client = Registry(database_uri, event_loop=asyncio.get_running_loop)
Expand Down
2 changes: 1 addition & 1 deletion tests/indexes/test_indexes.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from typing import Optional

import pytest
from tests.conftest import client

import mongoz
from mongoz import Document, Index, IndexType, ObjectId, Order
from mongoz.exceptions import InvalidKeyError
from tests.conftest import client

pytestmark = pytest.mark.anyio

Expand Down
2 changes: 1 addition & 1 deletion tests/indexes/test_indexes_auto_generate_true.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import pytest
from pymongo.errors import DuplicateKeyError
from tests.conftest import client

import mongoz
from mongoz import Document, Index, IndexType, ObjectId, Order
from tests.conftest import client

pytestmark = pytest.mark.anyio

Expand Down
2 changes: 1 addition & 1 deletion tests/indexes/test_indexes_duplicate_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import pytest
from pymongo.errors import DuplicateKeyError
from tests.conftest import client

import mongoz
from mongoz import Document, Index, IndexType, ObjectId, Order
from tests.conftest import client

pytestmark = pytest.mark.anyio

Expand Down
2 changes: 1 addition & 1 deletion tests/indexes/test_indexes_from_field.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from typing import Optional

import pytest
from tests.conftest import client

import mongoz
from mongoz import Document, Index, IndexType, ObjectId, Order
from mongoz.exceptions import InvalidKeyError
from tests.conftest import client

pytestmark = pytest.mark.anyio

Expand Down
2 changes: 1 addition & 1 deletion tests/indexes/test_indexes_raise_error.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from typing import Optional

import pytest
from tests.conftest import client

import mongoz
from mongoz import Document, Index, IndexType, ObjectId, Order
from mongoz.exceptions import IndexError
from tests.conftest import client

pytestmark = pytest.mark.anyio

Expand Down
2 changes: 1 addition & 1 deletion tests/indexes/test_unique.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import pydantic
import pytest
from pymongo.errors import DuplicateKeyError
from tests.conftest import client

import mongoz
from mongoz import Document
from tests.conftest import client

pytestmark = pytest.mark.anyio
pydantic_version = pydantic.__version__[:3]
Expand Down
2 changes: 1 addition & 1 deletion tests/inheritance/test_abstract_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import pydantic
import pytest
from tests.conftest import client

import mongoz
from mongoz import Document, Index, ObjectId
from mongoz.exceptions import AbstractDocumentError
from tests.conftest import client

pytestmark = pytest.mark.anyio
pydantic_version = pydantic.__version__[:3]
Expand Down
2 changes: 1 addition & 1 deletion tests/inheritance/test_inheritance.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import pydantic
import pytest
from tests.conftest import client

import mongoz
from mongoz import Document, ObjectId
from tests.conftest import client

pytestmark = pytest.mark.anyio
pydantic_version = pydantic.__version__[:3]
Expand Down
2 changes: 1 addition & 1 deletion tests/inheritance/test_inheritance_non_abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import pydantic
import pytest
from tests.conftest import client

import mongoz
from mongoz import Document, ObjectId
from tests.conftest import client

pytestmark = pytest.mark.anyio
pydantic_version = pydantic.__version__[:3]
Expand Down
2 changes: 1 addition & 1 deletion tests/inheritance/test_inherited_client_and_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import pydantic
import pytest
from tests.conftest import client

import mongoz
from mongoz import Document, Index, ObjectId
from tests.conftest import client

pytestmark = pytest.mark.anyio
pydantic_version = pydantic.__version__[:3]
Expand Down
2 changes: 1 addition & 1 deletion tests/integrations/test_esmerald.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import pytest
from esmerald import Esmerald, Gateway, JSONResponse, Request, get, post
from esmerald.testclient import EsmeraldTestClient
from tests.conftest import client

import mongoz
from mongoz import Document
from tests.conftest import client

pytestmark = pytest.mark.anyio

Expand Down
2 changes: 1 addition & 1 deletion tests/integrations/test_lilya.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
from lilya.responses import Ok
from lilya.routing import Path
from lilya.testclient import TestClient
from tests.conftest import client

import mongoz
from mongoz import Document
from tests.conftest import client

pytestmark = pytest.mark.anyio

Expand Down
2 changes: 1 addition & 1 deletion tests/models/manager/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import pydantic
import pytest
from tests.conftest import client

import mongoz
from mongoz import Document, Index, IndexType, ObjectId, Order
from tests.conftest import client

pytestmark = pytest.mark.anyio
pydantic_version = pydantic.__version__[:3]
Expand Down
2 changes: 1 addition & 1 deletion tests/models/manager/test_array_and_array_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import pydantic
import pytest
from pydantic import ValidationError
from tests.conftest import client

import mongoz
from mongoz import Document, ObjectId
from tests.conftest import client

pytestmark = pytest.mark.anyio
pydantic_version = pydantic.__version__[:3]
Expand Down
2 changes: 1 addition & 1 deletion tests/models/manager/test_boolean_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import pydantic
import pytest
from tests.conftest import client

import mongoz
from mongoz import Document, Index, IndexType, ObjectId, Order
from tests.conftest import client

pytestmark = pytest.mark.anyio
pydantic_version = pydantic.__version__[:3]
Expand Down
2 changes: 1 addition & 1 deletion tests/models/manager/test_bulk_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import pydantic
import pytest
from tests.conftest import client

import mongoz
from mongoz import Document, Index, IndexType, ObjectId, Order
from tests.conftest import client

pytestmark = pytest.mark.anyio
pydantic_version = pydantic.__version__[:3]
Expand Down
2 changes: 1 addition & 1 deletion tests/models/manager/test_count.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import pydantic
import pytest
from tests.conftest import client

import mongoz
from mongoz import Document, Index, IndexType, ObjectId, Order
from tests.conftest import client

pytestmark = pytest.mark.anyio
pydantic_version = pydantic.__version__[:3]
Expand Down
2 changes: 1 addition & 1 deletion tests/models/manager/test_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import pytest
from pydantic import ValidationError
from pymongo import errors
from tests.conftest import client

import mongoz
from mongoz import Document, Index, IndexType, ObjectId, Order
from tests.conftest import client

pytestmark = pytest.mark.anyio
pydantic_version = pydantic.__version__[:3]
Expand Down
2 changes: 1 addition & 1 deletion tests/models/manager/test_create_many.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import bson
import pydantic
import pytest
from tests.conftest import client

import mongoz
from mongoz import Document, Index, IndexType, ObjectId, Order
from tests.conftest import client

pytestmark = pytest.mark.anyio
pydantic_version = pydantic.__version__[:3]
Expand Down
2 changes: 1 addition & 1 deletion tests/models/manager/test_create_on_save.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import pydantic
import pytest
from tests.conftest import client

import mongoz
from mongoz import Document, ObjectId
from tests.conftest import client

pytestmark = pytest.mark.anyio
pydantic_version = pydantic.__version__[:3]
Expand Down
2 changes: 1 addition & 1 deletion tests/models/manager/test_custom_query_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

import pydantic
import pytest
from tests.conftest import client

import mongoz
from mongoz import Document, Index, IndexType, ObjectId, Order
from tests.conftest import client

pytestmark = pytest.mark.anyio
pydantic_version = pydantic.__version__[:3]
Expand Down
2 changes: 1 addition & 1 deletion tests/models/manager/test_defer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import pydantic
import pytest
from tests.conftest import client

import mongoz
from mongoz import Document, Index, IndexType, ObjectId, Order
from tests.conftest import client

pytestmark = pytest.mark.anyio
pydantic_version = pydantic.__version__[:3]
Expand Down
Loading

0 comments on commit c6ae175

Please sign in to comment.