pomcorn 0.7.5__tar.gz → 0.8.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pomcorn might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pomcorn
3
- Version: 0.7.5
3
+ Version: 0.8.0
4
4
  Summary: Base implementation of Page Object Model
5
5
  Home-page: https://pypi.org/project/pomcorn/
6
6
  License: MIT
@@ -1,4 +1,4 @@
1
- from typing import Generic, TypeVar, overload
1
+ from typing import Generic, TypeVar, get_args, overload
2
2
 
3
3
  from . import locators
4
4
  from .element import XPathElement
@@ -177,21 +177,37 @@ class ListComponent(Generic[ListItemType, TPage], Component[TPage]):
177
177
  * all
178
178
  * get_item_by_text()
179
179
 
180
- Waits for `base_item_locator` property to be implemented and value of
181
- `item_class` to be set.
182
-
183
180
  Waits for `base_item_locator` property to be overridden or one of the
184
181
  attributes (`item_locator` or `relative_item_locator`) to be specified.
185
182
 
186
- The `item_class` attribute is also required.
187
-
188
183
  """
189
184
 
190
- item_class: type[ListItemType]
191
-
192
185
  item_locator: locators.XPathLocator | None = None
193
186
  relative_item_locator: locators.XPathLocator | None = None
194
187
 
188
+ def __init__(
189
+ self,
190
+ page: TPage,
191
+ base_locator: locators.XPathLocator | None = None,
192
+ wait_until_visible: bool = True,
193
+ ):
194
+ super().__init__(page, base_locator, wait_until_visible)
195
+ if item_class := getattr(self, "item_class", None):
196
+ import warnings
197
+
198
+ warnings.warn(
199
+ DeprecationWarning(
200
+ "\nSpecifying `item_class` attribute in `ListComponent` "
201
+ f"({self.__class__}) is DEPRECATED. It is now "
202
+ "automatically substituted from Generic[ListItemType]. "
203
+ "Ability to specify this attribute will be removed soon.",
204
+ ),
205
+ stacklevel=2,
206
+ )
207
+ self._item_class = item_class
208
+ else:
209
+ self._item_class = self._get_list_item_class()
210
+
195
211
  @property
196
212
  def base_item_locator(self) -> locators.XPathLocator:
197
213
  """Get the base locator of list item.
@@ -236,7 +252,9 @@ class ListComponent(Generic[ListItemType, TPage], Component[TPage]):
236
252
 
237
253
  items: list[ListItemType] = []
238
254
  for locator in self.iter_locators(self.base_item_locator):
239
- items.append(self.item_class(page=self.page, base_locator=locator))
255
+ items.append(
256
+ self._item_class(page=self.page, base_locator=locator),
257
+ )
240
258
  return items
241
259
 
242
260
  def get_item_by_text(self, text: str) -> ListItemType:
@@ -244,13 +262,17 @@ class ListComponent(Generic[ListItemType, TPage], Component[TPage]):
244
262
  locator = self.base_item_locator.extend_query(
245
263
  extra_query=f"[contains(.,'{text}')]",
246
264
  )
247
- return self.item_class(page=self.page, base_locator=locator)
265
+ return self._item_class(page=self.page, base_locator=locator)
266
+
267
+ def _get_list_item_class(self) -> type[ListItemType]:
268
+ """Return class passed in `Generic[ListItemType]`."""
269
+ return get_args(self.__orig_bases__[0])[0] # type: ignore
248
270
 
249
271
  def __repr__(self) -> str:
250
272
  return (
251
273
  "ListComponent("
252
274
  f"component={self.__class__}, "
253
- f"item_class={self.item_class}, "
275
+ f"item_class={self._item_class}, "
254
276
  f"base_item_locator={self.base_item_locator}, "
255
277
  f"count={self.count}, "
256
278
  f"items={self.all}, "
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "pomcorn"
3
- version = "0.7.5"
3
+ version = "0.8.0"
4
4
  description = "Base implementation of Page Object Model"
5
5
  authors = [
6
6
  "Saritasa <pypi@saritasa.com>",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes