Skip to content

Commit 0ba09d8

Browse files
feat: add AnnotatedStringInterface (#72)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Introduced a new interface for annotated strings, allowing for flag metadata and callable status to be associated with inputs and outputs. This enhances flexibility when working with annotated strings in rule definitions. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 035f375 commit 0ba09d8

File tree

1 file changed

+18
-0
lines changed
  • src/snakemake_interface_common

1 file changed

+18
-0
lines changed

src/snakemake_interface_common/io.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from abc import ABC, abstractmethod
2+
from typing import Any, Dict
3+
4+
5+
class AnnotatedStringInterface(ABC):
6+
"""Interface for annotated strings/callables as they are used for input/output in
7+
Snakemake rules.
8+
"""
9+
10+
@property
11+
@abstractmethod
12+
def flags(self) -> Dict[str, Any]: ...
13+
14+
@abstractmethod
15+
def is_callable(self) -> bool: ...
16+
17+
def is_flagged(self, flag: str) -> bool:
18+
return flag in self.flags and bool(self.flags[flag])

0 commit comments

Comments
 (0)