Skip to content

Commit

Permalink
Remove postponed annotations from web_poet.pages.
Browse files Browse the repository at this point in the history
  • Loading branch information
wRAR committed Feb 8, 2025
1 parent 4246c1d commit 1641d77
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ ignore = [
# Move application import {} into a type-checking block
# (The fix can break singledispatch() and/or andi.)
"TC001",
# Add `from __future__ import annotations` to simplify
# (The fix can break singledispatch() and/or andi.)
"FA100",
]

[tool.ruff.lint.per-file-ignores]
Expand Down
15 changes: 5 additions & 10 deletions web_poet/pages.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
from __future__ import annotations

import abc
import inspect
from contextlib import suppress
from functools import wraps
from typing import TYPE_CHECKING, Any, Generic, TypeVar, overload
from typing import Any, Generic, Optional, TypeVar, overload

import attr
import parsel

from web_poet.fields import FieldsMixin, item_from_fields
from web_poet.mixins import ResponseShortcutsMixin, SelectorShortcutsMixin
from web_poet.page_inputs import HttpResponse
from web_poet.utils import (
CallableT,
_create_deprecated_class,
cached_method,
get_generic_param,
)

if TYPE_CHECKING:
import parsel

from web_poet.page_inputs import HttpResponse


class Injectable(abc.ABC, FieldsMixin):
"""Base Page Object class, which all Page Objects should inherit from
Expand Down Expand Up @@ -62,10 +57,10 @@ def get_item_cls(cls: type, default: type) -> type: ...


@overload
def get_item_cls(cls: type, default: None) -> type | None: ...
def get_item_cls(cls: type, default: None) -> Optional[type]: ...


def get_item_cls(cls: type, default: type | None = None) -> type | None:
def get_item_cls(cls: type, default: Optional[type] = None) -> Optional[type]:
param = get_generic_param(cls, Returns)
return param or default

Expand Down

0 comments on commit 1641d77

Please sign in to comment.