Skip to content

Remove leftovers from pytest from _pytask.mark.Mark. #219

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

Merged
merged 1 commit into from
Feb 17, 2022
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
1 change: 1 addition & 0 deletions docs/source/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ all releases are available on `PyPI <https://pypi.org/project/pytask>`_ and

- :gh:`217` enhances the tutorial on how to set up a project.
- :gh:`218` removes ``depends_on`` and ``produces`` from the task function when parsed.
- :gh:`219` removes some leftovers from pytest in :class:`~_pytask.mark.Mark`.


0.1.8 - 2022-02-07
Expand Down
32 changes: 5 additions & 27 deletions src/_pytask/mark/structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
from typing import Callable
from typing import Iterable
from typing import Mapping
from typing import Optional
from typing import Sequence
from typing import Tuple

import attr

Expand All @@ -16,25 +13,15 @@ def is_task_function(func: Any) -> bool:
return callable(func) and getattr(func, "__name__", "<lambda>") != "<lambda>"


@attr.s(frozen=True)
@attr.s(frozen=True, auto_attribs=True)
class Mark:
name = attr.ib(type=str)
name: str
"""str: Name of the mark."""
args = attr.ib(type=Tuple[Any, ...])
args: tuple[Any, ...]
"""Tuple[Any]: Positional arguments of the mark decorator."""
kwargs = attr.ib(type=Mapping[str, Any])
kwargs: Mapping[str, Any]
"""Mapping[str, Any]: Keyword arguments of the mark decorator."""

_param_ids_from = attr.ib(type=Optional["Mark"], default=None, repr=False)
"""Optional[Mark]: Source Mark for ids with parametrize Marks."""
_param_ids_generated = attr.ib(
type=Optional[Sequence[str]], default=None, repr=False
)
"""Optional[Sequence[str]]: Resolved/generated ids with parametrize Marks."""

def _has_param_ids(self) -> bool:
return "ids" in self.kwargs or len(self.args) >= 4

def combined_with(self, other: Mark) -> Mark:
"""Return a new Mark which is a combination of this Mark and another Mark.

Expand All @@ -53,19 +40,10 @@ def combined_with(self, other: Mark) -> Mark:
"""
assert self.name == other.name

# Remember source of ids with parametrize Marks.
param_ids_from: Mark | None = None
if self.name == "parametrize":
if other._has_param_ids():
param_ids_from = other
elif self._has_param_ids():
param_ids_from = self

return Mark(
self.name,
self.args + other.args,
dict(self.kwargs, **other.kwargs),
param_ids_from=param_ids_from,
{**self.kwargs, **other.kwargs},
)


Expand Down