Skip to content

Commit

Permalink
Remove deprecated functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
wRAR committed Jan 25, 2025
1 parent d06195a commit f2c380b
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 108 deletions.
52 changes: 0 additions & 52 deletions itemadapter/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import warnings
from types import MappingProxyType
from typing import Any

Expand Down Expand Up @@ -77,54 +76,3 @@ def get_field_meta_from_class(item_class: type, field_name: str) -> MappingProxy
from itemadapter.adapter import ItemAdapter

return ItemAdapter.get_field_meta_from_class(item_class, field_name)


# deprecated


def is_dataclass_instance(obj: Any) -> bool:
warnings.warn(
"itemadapter.utils.is_dataclass_instance is deprecated"
" and it will be removed in a future version",
category=DeprecationWarning,
stacklevel=2,
)
from itemadapter.adapter import DataclassAdapter

return DataclassAdapter.is_item(obj)


def is_attrs_instance(obj: Any) -> bool:
warnings.warn(
"itemadapter.utils.is_attrs_instance is deprecated"
" and it will be removed in a future version",
category=DeprecationWarning,
stacklevel=2,
)
from itemadapter.adapter import AttrsAdapter

return AttrsAdapter.is_item(obj)


def is_pydantic_instance(obj: Any) -> bool:
warnings.warn(
"itemadapter.utils.is_pydantic_instance is deprecated"
" and it will be removed in a future version",
category=DeprecationWarning,
stacklevel=2,
)
from itemadapter.adapter import PydanticAdapter

return PydanticAdapter.is_item(obj)


def is_scrapy_item(obj: Any) -> bool:
warnings.warn(
"itemadapter.utils.is_scrapy_item is deprecated"
" and it will be removed in a future version",
category=DeprecationWarning,
stacklevel=2,
)
from itemadapter.adapter import ScrapyItemAdapter

return ScrapyItemAdapter.is_item(obj)
14 changes: 0 additions & 14 deletions tests/test_adapter_attrs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import unittest
import warnings
from types import MappingProxyType
from unittest import mock

Expand Down Expand Up @@ -75,16 +74,3 @@ def test_true(self):
)
with self.assertRaises(KeyError, msg="AttrsItem does not support field: non_existent"):
get_field_meta_from_class(AttrsItem, "non_existent")

def test_deprecated_is_instance(self):
from itemadapter.utils import is_attrs_instance

with warnings.catch_warnings(record=True) as caught:
is_attrs_instance(1)
self.assertEqual(len(caught), 1)
self.assertTrue(issubclass(caught[0].category, DeprecationWarning))
self.assertEqual(
"itemadapter.utils.is_attrs_instance is deprecated"
" and it will be removed in a future version",
str(caught[0].message),
)
14 changes: 0 additions & 14 deletions tests/test_adapter_dataclasses.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import warnings
from types import MappingProxyType
from unittest import TestCase

Expand Down Expand Up @@ -47,16 +46,3 @@ def test_true(self):
)
with self.assertRaises(KeyError, msg="DataClassItem does not support field: non_existent"):
get_field_meta_from_class(DataClassItem, "non_existent")

def test_deprecated_is_instance(self):
from itemadapter.utils import is_dataclass_instance

with warnings.catch_warnings(record=True) as caught:
is_dataclass_instance(1)
self.assertEqual(len(caught), 1)
self.assertTrue(issubclass(caught[0].category, DeprecationWarning))
self.assertEqual(
"itemadapter.utils.is_dataclass_instance is deprecated"
" and it will be removed in a future version",
str(caught[0].message),
)
14 changes: 0 additions & 14 deletions tests/test_adapter_pydantic.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import unittest
import warnings
from types import MappingProxyType
from unittest import mock

Expand Down Expand Up @@ -76,16 +75,3 @@ def test_true(self):
)
with self.assertRaises(KeyError, msg="PydanticModel does not support field: non_existent"):
get_field_meta_from_class(PydanticModel, "non_existent")

def test_deprecated_is_instance(self):
from itemadapter.utils import is_pydantic_instance

with warnings.catch_warnings(record=True) as caught:
is_pydantic_instance(1)
self.assertEqual(len(caught), 1)
self.assertTrue(issubclass(caught[0].category, DeprecationWarning))
self.assertEqual(
"itemadapter.utils.is_pydantic_instance is deprecated"
" and it will be removed in a future version",
str(caught[0].message),
)
14 changes: 0 additions & 14 deletions tests/test_adapter_scrapy.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import unittest
import warnings
from types import MappingProxyType
from unittest import mock

Expand Down Expand Up @@ -74,19 +73,6 @@ def test_true(self):
MappingProxyType({"serializer": int}),
)

def test_deprecated_is_instance(self):
from itemadapter.utils import is_scrapy_item

with warnings.catch_warnings(record=True) as caught:
is_scrapy_item(1)
self.assertEqual(len(caught), 1)
self.assertTrue(issubclass(caught[0].category, DeprecationWarning))
self.assertEqual(
"itemadapter.utils.is_scrapy_item is deprecated"
" and it will be removed in a future version",
str(caught[0].message),
)


try:
import scrapy
Expand Down

0 comments on commit f2c380b

Please sign in to comment.