fix: disable UP040, revert some instances to TypeAlias

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
This commit is contained in:
Akhil Narang 2025-12-22 19:00:38 +05:30
parent 7aec123a29
commit e859b1d312
No known key found for this signature in database
GPG key ID: 9DCC61E211BF645F
4 changed files with 17 additions and 15 deletions

View file

@ -1,8 +1,11 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: MIT. See LICENSE
from __future__ import annotations
import json
from collections import defaultdict
from typing import TYPE_CHECKING, Union
from typing import TYPE_CHECKING
import frappe
from frappe import _
@ -40,7 +43,7 @@ def get_workflow_name(doctype):
@frappe.whitelist()
def get_transitions(
doc: "Document" | str | dict, workflow: "Workflow" = None, raise_exception: bool = False
doc: Document | str | dict, workflow: Workflow = None, raise_exception: bool = False
) -> list[dict]:
"""Return list of possible transitions for the given doc"""
from frappe.model.document import Document

View file

@ -8,20 +8,20 @@ from typing import Any, NamedTuple, Self, TypeAlias, TypeGuard, TypeVar, cast, o
from pypika import Column
type Doct = str
type Fld = str
type Op = str
type DateTime = datetime | date
type _Value = str | int | float | None | DateTime | Column
type _InputValue = _Value | bool
type Value = _Value | Sequence[_Value]
type InputValue = _InputValue | Sequence[_InputValue]
Doct: TypeAlias = str
Fld: TypeAlias = str
Op: TypeAlias = str
DateTime: TypeAlias = datetime | date
_Value: TypeAlias = str | int | float | None | DateTime | Column
_InputValue: TypeAlias = _Value | bool
Value: TypeAlias = _Value | Sequence[_Value]
InputValue: TypeAlias = _InputValue | Sequence[_InputValue]
type FilterTupleSpec = (
FilterTupleSpec: TypeAlias = (
tuple[Fld, InputValue] | tuple[Fld, Op, InputValue] | tuple[Doct, Fld, Op, InputValue]
)
type FilterMappingSpec = Mapping[Fld, _InputValue | tuple[Op, InputValue]]
FilterMappingSpec: TypeAlias = Mapping[Fld, _InputValue | tuple[Op, InputValue]]
class Sentinel:
@ -35,8 +35,6 @@ class Sentinel:
UNSPECIFIED = Sentinel()
T = TypeVar("T")
def is_unspecified[T](value: T | Sentinel) -> TypeGuard[Sentinel]:
return value is UNSPECIFIED

View file

@ -46,7 +46,7 @@ EMAIL_MATCH_PATTERN = re.compile(
UNSET = object()
type PropertyType = property | functools.cached_property
PropertyType: TypeAlias = property | functools.cached_property
def get_fullname(user=None):

View file

@ -190,6 +190,7 @@ ignore = [
"UP031", # Use format specifiers instead of percent format
"UP032", # Use f-string instead of `format` call (translations)
"UP037", # quoted annotations
"UP040", # Use type aliases instead of type annotations
]
typing-modules = ["frappe.types.DF"]