Skip to content

Commit

Permalink
Merge pull request #41 from pomponchik/develop
Browse files Browse the repository at this point in the history
0.0.30
  • Loading branch information
pomponchik authored Aug 16, 2024
2 parents a410e02 + 0ad02ad commit c87b700
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
12 changes: 8 additions & 4 deletions cantok/tokens/condition_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,16 @@ def run_function(self) -> bool:
return result

def text_representation_of_superpower(self) -> str:
result = self.function.__name__
if hasattr(self.function, '__name__'):
result = self.function.__name__

if result == '<lambda>':
return 'λ'
if result == '<lambda>':
return 'λ'

return result
return result

else:
return repr(self.function)

def get_extra_kwargs(self) -> Dict[str, Any]:
result = {}
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "cantok"
version = "0.0.29"
version = "0.0.30"
authors = [
{ name="Evgeniy Blinov", email="zheni-b@yandex.ru" },
]
Expand Down
14 changes: 14 additions & 0 deletions tests/units/tokens/test_condition_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,3 +461,17 @@ def function(): return False
assert repr(ConditionToken(function, suppress_exceptions=False, default=True)) == 'ConditionToken(function, suppress_exceptions=False, default=True)'

assert repr(ConditionToken(function, suppress_exceptions=False, default=True, cancelled=True)) == 'ConditionToken(function, cancelled=True, suppress_exceptions=False, default=True)'


def test_repr_for_class_based_function():
class SomeChecker:
def __call__(self) -> bool:
return True

def __str__(self) -> str:
return 'str_string'

def __repr__(self) -> str:
return 'repr_string'

assert repr(ConditionToken(SomeChecker())) == 'ConditionToken(repr_string)'

0 comments on commit c87b700

Please sign in to comment.