Skip to content
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

feat: Guards now support the evaluation of **truthy**** and **falsy** and can be assigned as decorators #342

Merged
merged 1 commit into from Jan 28, 2023

Conversation

fgmacedo
Copy link
Owner

@fgmacedo fgmacedo commented Jan 28, 2023

Guards now support the evaluation of truthy and falsy values, and can be assigned as decorators.

Note about truthy and falsy values

In Python, a boolean value is either True or False. However, there are also specific values that
are considered "falsy" and will evaluate as False when used in a boolean context.

These include:

  1. The special value None.
  2. Numeric values of 0 or 0.0.
  3. Empty strings, lists, tuples, sets, and dictionaries.
  4. Instances of certain classes that define a __bool__() or __len__() method that returns
    False or 0, respectively.

On the other hand, any value that is not considered "falsy" is considered "truthy" and will evaluate as True when used in a boolean context.

So, a condition s1.to(s2, cond=lambda: []) will evaluate to False, as an empty list is a
falsy value.

@codecov
Copy link

codecov bot commented Jan 28, 2023

Codecov Report

Base: 100.00% // Head: 100.00% // No change to project coverage 👍

Coverage data is based on head (6113a1e) compared to base (b4587dc).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff            @@
##           develop      #342   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           17        17           
  Lines          792       800    +8     
  Branches       112       112           
=========================================
+ Hits           792       800    +8     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
statemachine/callbacks.py 100.00% <100.00%> (ø)
statemachine/contrib/diagram.py 100.00% <100.00%> (ø)
statemachine/transition_list.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@fgmacedo fgmacedo force-pushed the macedo/transitionlist-with-guards-support branch from 2efea0f to 4aa9898 Compare January 28, 2023 21:19
@fgmacedo fgmacedo force-pushed the macedo/transitionlist-with-guards-support branch from 4aa9898 to 6113a1e Compare January 28, 2023 21:41
@sonarcloud
Copy link

sonarcloud bot commented Jan 28, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@fgmacedo fgmacedo merged commit f1afe5a into develop Jan 28, 2023
@fgmacedo fgmacedo deleted the macedo/transitionlist-with-guards-support branch January 28, 2023 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant