Add mcoplib mcoplib profiler bool env#55
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the _is_profiler_enabled function in mcoplib/profiler.py to support a wider range of falsy environment variable values (such as 'false', 'off', and 'no') and adds corresponding unit tests. The feedback suggests simplifying the implementation by removing the redundant try-except block and str() conversion, since the environment variable is guaranteed to be a string.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| v = os.getenv("PROFILER_ENABLED", "1") | ||
| try: | ||
| return not (str(v).strip() == "0") | ||
| return str(v).strip().lower() not in {"0", "false", "off", "no"} | ||
| except Exception: | ||
| return True |
There was a problem hiding this comment.
The try-except block and the str(v) conversion are redundant here. Since os.getenv is called with a default string value of "1", v is guaranteed to be a string. String operations like .strip() and .lower() as well as the set membership check will not raise any exceptions under normal execution. Removing the redundant try-except block and str() conversion simplifies the code and improves readability.
v = os.getenv("PROFILER_ENABLED", "1")
return v.strip().lower() not in {"0", "false", "off", "no"}
Summary
Validation
Review notes