https://github.com/dluman/pennant
A high-spirited feature-flagging library for Python.
https://github.com/dluman/pennant
conditional-execution feature-flags feature-toggles features flagging flags rollout
Last synced: 3 months ago
JSON representation
A high-spirited feature-flagging library for Python.
- Host: GitHub
- URL: https://github.com/dluman/pennant
- Owner: dluman
- License: unlicense
- Created: 2024-01-08T15:57:02.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-08T17:19:04.000Z (over 1 year ago)
- Last Synced: 2025-02-18T17:54:05.799Z (4 months ago)
- Topics: conditional-execution, feature-flags, feature-toggles, features, flagging, flags, rollout
- Language: Python
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pennant
[](https://pypi.org/project/pennant/)
A feature flagging library that uses decorators and context management to "feature flag" certain
functions or blocks of code. I _feel_ like it's better than a bunch of conditionals, but I'm often
wrong.## Installation
Find this tool on `PyPI`: `pip install pennant`
## Usage
Contrary to how some folks might do it, this library takes and "opt-out" approach where setting the flag to
`False` prevents the given function or code block from running. As long as the argument provided to the
decorator or content manager evaluates to `False`, anything's game.Check this out:
```python
import pennant@pennant.FEATURE_FLAG_FUNCTION(False)
def print_me(test: str = "Hello!") -> str:
print(test)
return "!"def main():
print("This should run none of the following.")
print_me(test = "Yes!")
with pennant.FEATURE_FLAG_CODE(False):
numbers = [1,2]
print(numbers)if __name__ == "__main__":
main()
```