Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade ruff=0.8.6 #5393

Merged
merged 1 commit into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ jobs:
with:
submodules: true
- name: "Setup environment"
run: "pip install ruff==0.7.1"
run: "pip install ruff==0.8.6"
- name: "Linting: ruff check"
run: "ruff check . --exclude python_sdk"
- name: "Linting: ruff format"
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ repos:

- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.7.1
rev: v0.8.6
hooks:
# Run the linter.
- id: ruff
Expand Down
2 changes: 1 addition & 1 deletion backend/infrahub/api/artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from infrahub.core.account import ObjectPermission
from infrahub.core.constants import GLOBAL_BRANCH_NAME, InfrahubKind, PermissionAction
from infrahub.core.protocols import CoreArtifactDefinition
from infrahub.database import InfrahubDatabase # noqa: TCH001
from infrahub.database import InfrahubDatabase # noqa: TC001
from infrahub.exceptions import NodeNotFoundError
from infrahub.git.models import RequestArtifactDefinitionGenerate
from infrahub.log import get_logger
Expand Down
4 changes: 2 additions & 2 deletions backend/infrahub/api/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

from infrahub import config
from infrahub.auth import AccountSession, authentication_token, validate_jwt_access_token, validate_jwt_refresh_token
from infrahub.core.branch import Branch # noqa: TCH001
from infrahub.core.branch import Branch # noqa: TC001
from infrahub.core.registry import registry
from infrahub.core.timestamp import Timestamp
from infrahub.database import InfrahubDatabase # noqa: TCH001
from infrahub.database import InfrahubDatabase # noqa: TC001
from infrahub.exceptions import AuthorizationError
from infrahub.permissions import PermissionManager

Expand Down
4 changes: 2 additions & 2 deletions backend/infrahub/api/diff/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@

from infrahub.api.dependencies import get_branch_dep, get_current_user, get_db
from infrahub.core import registry
from infrahub.core.branch import Branch # noqa: TCH001
from infrahub.core.branch import Branch # noqa: TC001
from infrahub.core.diff.artifacts.calculator import ArtifactDiffCalculator
from infrahub.core.diff.branch_differ import BranchDiffer
from infrahub.core.diff.model.diff import (
BranchDiffArtifact,
BranchDiffFile,
BranchDiffRepository,
)
from infrahub.database import InfrahubDatabase # noqa: TCH001
from infrahub.database import InfrahubDatabase # noqa: TC001

if TYPE_CHECKING:
from infrahub.services import InfrahubServices
Expand Down
2 changes: 1 addition & 1 deletion backend/infrahub/api/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from infrahub.api.dependencies import BranchParams, get_branch_params, get_current_user, get_db
from infrahub.core.constants import InfrahubKind
from infrahub.core.manager import NodeManager
from infrahub.database import InfrahubDatabase # noqa: TCH001
from infrahub.database import InfrahubDatabase # noqa: TC001
from infrahub.exceptions import CommitNotFoundError, PropagatedFromWorkerError
from infrahub.message_bus.messages import GitFileGet, GitFileGetResponse

Expand Down
4 changes: 2 additions & 2 deletions backend/infrahub/api/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

from infrahub.api.dependencies import get_branch_dep, get_db, get_permission_manager
from infrahub.core import registry
from infrahub.core.branch import Branch # noqa: TCH001
from infrahub.core.branch import Branch # noqa: TC001
from infrahub.core.protocols import CoreMenuItem
from infrahub.log import get_logger
from infrahub.menu.generator import generate_restricted_menu
from infrahub.menu.models import Menu # noqa: TCH001
from infrahub.menu.models import Menu # noqa: TC001

if TYPE_CHECKING:
from infrahub.database import InfrahubDatabase
Expand Down
2 changes: 1 addition & 1 deletion backend/infrahub/api/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from infrahub.core import registry
from infrahub.core.constants import InfrahubKind
from infrahub.core.protocols import CoreGraphQLQuery
from infrahub.database import InfrahubDatabase # noqa: TCH001
from infrahub.database import InfrahubDatabase # noqa: TC001
from infrahub.graphql.analyzer import InfrahubGraphQLQueryAnalyzer
from infrahub.graphql.api.dependencies import build_graphql_query_permission_checker
from infrahub.graphql.initialization import prepare_graphql_params
Expand Down
8 changes: 4 additions & 4 deletions backend/infrahub/api/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@
from infrahub.api.exceptions import SchemaNotValidError
from infrahub.core import registry
from infrahub.core.account import GlobalPermission
from infrahub.core.branch import Branch # noqa: TCH001
from infrahub.core.branch import Branch # noqa: TC001
from infrahub.core.constants import GLOBAL_BRANCH_NAME, GlobalPermissions, PermissionDecision
from infrahub.core.migrations.schema.models import SchemaApplyMigrationData
from infrahub.core.models import ( # noqa: TCH001
from infrahub.core.models import ( # noqa: TC001
SchemaBranchHash,
SchemaDiff,
SchemaUpdateValidationResult,
)
from infrahub.core.schema import GenericSchema, MainSchemaTypes, NodeSchema, ProfileSchema, SchemaRoot
from infrahub.core.schema.constants import SchemaNamespace # noqa: TCH001
from infrahub.core.schema.constants import SchemaNamespace # noqa: TC001
from infrahub.core.validators.models.validate_migration import (
SchemaValidateMigrationData,
SchemaValidatorPathResponseData,
)
from infrahub.database import InfrahubDatabase # noqa: TCH001
from infrahub.database import InfrahubDatabase # noqa: TC001
from infrahub.events import EventMeta
from infrahub.events.schema_action import SchemaUpdatedEvent
from infrahub.exceptions import MigrationError
Expand Down
2 changes: 1 addition & 1 deletion backend/infrahub/api/transformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
CoreTransformJinja2,
CoreTransformPython,
)
from infrahub.database import InfrahubDatabase # noqa: TCH001
from infrahub.database import InfrahubDatabase # noqa: TC001
from infrahub.exceptions import TransformError
from infrahub.graphql.initialization import prepare_graphql_params
from infrahub.graphql.utils import extract_data
Expand Down
2 changes: 1 addition & 1 deletion backend/infrahub/computed_attribute/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from dataclasses import dataclass, field
from typing import TYPE_CHECKING

from prefect.events.schemas.automations import Automation # noqa: TCH002
from prefect.events.schemas.automations import Automation # noqa: TC002
from pydantic import BaseModel, Field
from typing_extensions import Self

Expand Down
2 changes: 1 addition & 1 deletion backend/infrahub/computed_attribute/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import TYPE_CHECKING, Any

import ujson
from infrahub_sdk.protocols import CoreNode # noqa: TCH002
from infrahub_sdk.protocols import CoreNode # noqa: TC002
from prefect import flow
from prefect.automations import AutomationCore
from prefect.client.orchestration import get_client
Expand Down
2 changes: 1 addition & 1 deletion backend/infrahub/core/branch/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from infrahub.core.constants import (
GLOBAL_BRANCH_NAME,
)
from infrahub.core.models import SchemaBranchHash # noqa: TCH001
from infrahub.core.models import SchemaBranchHash # noqa: TC001
from infrahub.core.node.standard import StandardNode
from infrahub.core.query import QueryType
from infrahub.core.query.branch import (
Expand Down
4 changes: 2 additions & 2 deletions backend/infrahub/core/branch/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from prefect.automations import AutomationCore
from prefect.client.orchestration import get_client
from prefect.client.schemas.filters import DeploymentFilter, DeploymentFilterName
from prefect.client.schemas.objects import State # noqa: TCH002
from prefect.client.schemas.objects import State # noqa: TC002
from prefect.events.actions import RunDeployment
from prefect.events.schemas.automations import EventTrigger, Posture
from prefect.states import Completed, Failed
Expand All @@ -30,7 +30,7 @@
from infrahub.dependencies.registry import get_component_registry
from infrahub.events.branch_action import BranchCreateEvent, BranchDeleteEvent, BranchRebaseEvent
from infrahub.exceptions import BranchNotFoundError, MergeFailedError, ValidationError
from infrahub.graphql.mutations.models import BranchCreateModel # noqa: TCH001
from infrahub.graphql.mutations.models import BranchCreateModel # noqa: TC001
from infrahub.log import get_log_data
from infrahub.message_bus import Meta, messages
from infrahub.services import services
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import TYPE_CHECKING, Sequence

from infrahub.core.migrations.shared import MigrationResult
from infrahub.core.query import Query # noqa: TCH001
from infrahub.core.query import Query # noqa: TC001
from infrahub.database import DatabaseType
from infrahub.database.constants import IndexType
from infrahub.database.index import IndexItem
Expand Down
4 changes: 2 additions & 2 deletions backend/infrahub/core/migrations/schema/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
from prefect.cache_policies import NONE
from prefect.logging import get_run_logger

from infrahub.core.branch import Branch # noqa: TCH001
from infrahub.core.branch import Branch # noqa: TC001
from infrahub.core.migrations import MIGRATION_MAP
from infrahub.core.path import SchemaPath # noqa: TCH001
from infrahub.core.path import SchemaPath # noqa: TC001
from infrahub.services import services
from infrahub.workflows.utils import add_branch_tag

Expand Down
6 changes: 3 additions & 3 deletions backend/infrahub/core/migrations/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from typing_extensions import Self

from infrahub.core import registry
from infrahub.core.path import SchemaPath # noqa: TCH001
from infrahub.core.query import Query # noqa: TCH001
from infrahub.core.path import SchemaPath # noqa: TC001
from infrahub.core.query import Query # noqa: TC001
from infrahub.core.schema import (
AttributeSchema,
GenericSchema,
Expand All @@ -17,7 +17,7 @@
internal_schema,
)

from .query import MigrationQuery # noqa: TCH001
from .query import MigrationQuery # noqa: TC001

if TYPE_CHECKING:
from infrahub.core.branch import Branch
Expand Down
4 changes: 2 additions & 2 deletions backend/infrahub/core/schema/generated/attribute_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

from infrahub.core.constants import AllowOverrideType, HashableModelState
from infrahub.core.models import HashableModel
from infrahub.core.schema.computed_attribute import ComputedAttribute # noqa: TCH001
from infrahub.core.schema.dropdown import DropdownChoice # noqa: TCH001
from infrahub.core.schema.computed_attribute import ComputedAttribute # noqa: TC001
from infrahub.core.schema.dropdown import DropdownChoice # noqa: TC001

if TYPE_CHECKING:
from infrahub.core.constants import BranchSupportType
Expand Down
4 changes: 2 additions & 2 deletions backend/infrahub/core/schema/generated/base_node_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

from infrahub.core.constants import BranchSupportType, HashableModelState
from infrahub.core.models import HashableModel
from infrahub.core.schema.attribute_schema import AttributeSchema # noqa: TCH001
from infrahub.core.schema.relationship_schema import RelationshipSchema # noqa: TCH001
from infrahub.core.schema.attribute_schema import AttributeSchema # noqa: TC001
from infrahub.core.schema.relationship_schema import RelationshipSchema # noqa: TC001


class GeneratedBaseNodeSchema(HashableModel):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
RelationshipDeleteBehavior,
RelationshipDirection,
RelationshipKind,
)
) # noqa: TC001
from infrahub.core.models import HashableModel


Expand Down
2 changes: 1 addition & 1 deletion backend/infrahub/core/schema/schema_branch_computed.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from pydantic import BaseModel, Field

from infrahub.core.schema import AttributeSchema # noqa: TCH001
from infrahub.core.schema import AttributeSchema # noqa: TC001

if TYPE_CHECKING:
from infrahub.core.schema import NodeSchema, SchemaAttributePath
Expand Down
2 changes: 1 addition & 1 deletion backend/infrahub/core/task/task_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from pydantic import ConfigDict, Field

from infrahub.core.constants import Severity # noqa: TCH001
from infrahub.core.constants import Severity # noqa: TC001
from infrahub.core.node.standard import StandardNode
from infrahub.core.query.task_log import TaskLogNodeCreateQuery
from infrahub.core.timestamp import current_timestamp
Expand Down
4 changes: 2 additions & 2 deletions backend/infrahub/core/validators/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

from typing import Any, Union

from infrahub.core.path import GroupedDataPaths, SchemaPath # noqa: TCH001
from infrahub.core.path import GroupedDataPaths, SchemaPath # noqa: TC001
from infrahub.core.query import Query, QueryType
from infrahub.core.schema import AttributeSchema, GenericSchema, NodeSchema, RelationshipSchema # noqa: TCH001
from infrahub.core.schema import AttributeSchema, GenericSchema, NodeSchema, RelationshipSchema # noqa: TC001


class SchemaValidatorQuery(Query):
Expand Down
6 changes: 3 additions & 3 deletions backend/infrahub/core/validators/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
from prefect.cache_policies import NONE
from prefect.logging import get_run_logger

from infrahub.core.branch import Branch # noqa: TCH001
from infrahub.core.path import SchemaPath # noqa: TCH001
from infrahub.core.schema import GenericSchema, NodeSchema # noqa: TCH001
from infrahub.core.branch import Branch # noqa: TC001
from infrahub.core.path import SchemaPath # noqa: TC001
from infrahub.core.schema import GenericSchema, NodeSchema # noqa: TC001
from infrahub.core.validators.aggregated_checker import AggregatedConstraintChecker
from infrahub.core.validators.model import (
SchemaConstraintValidatorRequest,
Expand Down
2 changes: 1 addition & 1 deletion backend/infrahub/database/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from pydantic import BaseModel

from .constants import EntityType, IndexType # noqa: TCH001
from .constants import EntityType, IndexType # noqa: TC001

if TYPE_CHECKING:
from infrahub.database import InfrahubDatabase
Expand Down
6 changes: 3 additions & 3 deletions backend/infrahub/git/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
from abc import ABC, abstractmethod
from pathlib import Path
from typing import TYPE_CHECKING, NoReturn, Optional, Union
from uuid import UUID # noqa: TCH003
from uuid import UUID # noqa: TC003

import git
from git import Blob, Repo
from git.exc import GitCommandError, InvalidGitRepositoryError
from git.refs.remote import RemoteReference
from infrahub_sdk import InfrahubClient # noqa: TCH002
from infrahub_sdk import InfrahubClient # noqa: TC002
from prefect import Flow, Task
from pydantic import BaseModel, ConfigDict, Field
from pydantic import ValidationError as PydanticValidationError
Expand All @@ -29,7 +29,7 @@
from infrahub.git.directory import get_repositories_directory, initialize_repositories_directory
from infrahub.git.worktree import Worktree
from infrahub.log import get_logger
from infrahub.services import InfrahubServices # noqa: TCH001
from infrahub.services import InfrahubServices # noqa: TC001

if TYPE_CHECKING:
from infrahub_sdk.branch import BranchData
Expand Down
2 changes: 1 addition & 1 deletion backend/infrahub/git/integrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import jinja2
import ujson
import yaml
from infrahub_sdk import InfrahubClient # noqa: TCH002
from infrahub_sdk import InfrahubClient # noqa: TC002
from infrahub_sdk.exceptions import ValidationError
from infrahub_sdk.protocols import (
CoreArtifact,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
RequestProposedChangeSchemaIntegrity,
RequestProposedChangeUserTests,
)
from infrahub.services import InfrahubServices # noqa: TCH001
from infrahub.services import InfrahubServices # noqa: TC001
from infrahub.workflows.catalogue import (
REQUEST_PROPOSED_CHANGE_DATA_INTEGRITY,
REQUEST_PROPOSED_CHANGE_REPOSITORY_CHECKS,
Expand Down
2 changes: 1 addition & 1 deletion backend/infrahub/message_bus/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import re
from enum import Enum

from infrahub_sdk.diff import NodeDiff # noqa: TCH002
from infrahub_sdk.diff import NodeDiff # noqa: TC002
from pydantic import BaseModel, Field

from infrahub.core.constants import InfrahubKind, RepositoryInternalStatus
Expand Down
2 changes: 1 addition & 1 deletion backend/infrahub/proposed_change/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from prefect import flow, task
from prefect.cache_policies import NONE
from prefect.client.schemas.objects import (
State, # noqa: TCH002
State, # noqa: TC002
)
from prefect.logging import get_run_logger
from prefect.states import Completed, Failed
Expand Down
4 changes: 2 additions & 2 deletions backend/templates/attributeschema_imports.j2
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ from typing import Optional, Any, TYPE_CHECKING

from infrahub.core.models import HashableModel
from infrahub.core.constants import AllowOverrideType, ComputedAttributeKind, HashableModelState
from infrahub.core.schema.computed_attribute import ComputedAttribute # noqa: TCH001
from infrahub.core.schema.dropdown import DropdownChoice # noqa: TCH001
from infrahub.core.schema.computed_attribute import ComputedAttribute # noqa: TC001
from infrahub.core.schema.dropdown import DropdownChoice # noqa: TC001

if TYPE_CHECKING:
from infrahub.core.constants import BranchSupportType
6 changes: 3 additions & 3 deletions backend/templates/basenodeschema_imports.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ from typing import Optional

from infrahub.core.constants import BranchSupportType, HashableModelState
from infrahub.core.models import HashableModel
from infrahub.core.schema.attribute_schema import AttributeSchema # noqa: TCH001
from infrahub.core.schema.filter import FilterSchema # noqa: TCH001
from infrahub.core.schema.relationship_schema import RelationshipSchema # noqa: TCH001
from infrahub.core.schema.attribute_schema import AttributeSchema # noqa: TC001
from infrahub.core.schema.filter import FilterSchema # noqa: TC001
from infrahub.core.schema.relationship_schema import RelationshipSchema # noqa: TC001
6 changes: 3 additions & 3 deletions backend/templates/genericschema_imports.j2
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Optional

from infrahub.core.constants import BranchSupportType, HashableModelState
from infrahub.core.schema.attribute_schema import AttributeSchema # noqa: TCH001
from infrahub.core.schema.attribute_schema import AttributeSchema # noqa: TC001
from infrahub.core.schema.basenode_schema import BaseNodeSchema
from infrahub.core.schema.filter import FilterSchema # noqa: TCH001
from infrahub.core.schema.relationship_schema import RelationshipSchema # noqa: TCH001
from infrahub.core.schema.filter import FilterSchema # noqa: TC001
from infrahub.core.schema.relationship_schema import RelationshipSchema # noqa: TC001
4 changes: 2 additions & 2 deletions backend/templates/relationshipschema_imports.j2
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Optional, TYPE_CHECKING

from infrahub.core.constants import AllowOverrideType, BranchSupportType, RelationshipKind, RelationshipCardinality, RelationshipDeleteBehavior, RelationshipDirection, HashableModelState # noqa: TCH001
from infrahub.core.constants import AllowOverrideType, BranchSupportType, RelationshipKind, RelationshipCardinality, RelationshipDeleteBehavior, RelationshipDirection, HashableModelState # noqa: TC001
from infrahub.core.models import HashableModel

if TYPE_CHECKING:
from infrahub.core.schema.filter import FilterSchema # noqa: TCH001
from infrahub.core.schema.filter import FilterSchema # noqa: TC001
Loading
Loading