Skip to content

Enhancement | Issue #21 | OPT-2 | Implement typed argument casting #307

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

exequielrafaela
Copy link
Member

@exequielrafaela exequielrafaela commented Jun 5, 2025

Summary

  • add as_bool/as_int/as_float helpers
  • update cast_value to use helper functions
  • extend parsing tests with edge cases
  • add dedicated casting tests

Testing

  • pytest tests/test__parsing.py tests/test_conf.py tests/test_casting.py -q
  • pytest -q

https://chatgpt.com/codex/tasks/task_e_6841c005a738832fba0a8e5381fda35d

Summary by CodeRabbit

  • New Features
    • Automatic conversion of string values to appropriate Python types (boolean, integer, float) when parsing arguments and loading configuration.
  • Bug Fixes
    • Improved handling of argument and configuration value types to ensure correct casting rather than treating all values as strings.
  • Tests
    • Added and enhanced tests to verify correct casting of argument and configuration values, including edge cases and special float values.

Copy link
Contributor

coderabbitai bot commented Jun 5, 2025

Walkthrough

A new casting utility module was introduced to convert string values to Python primitive types, and its functionality was integrated into configuration loading and argument parsing. Existing and new tests were updated or created to verify that values are now cast to appropriate types (booleans, integers, floats) instead of remaining as strings.

Changes

File(s) Change Summary
leverage/_casting.py New module implementing as_bool, as_int, as_float, and cast_value for type casting.
leverage/_parsing.py, leverage/conf.py Integrated cast_value to cast argument and config values during parsing and loading.
tests/test__parsing.py, tests/test_conf.py Updated tests to expect and assert casted (non-string) values for arguments and config variables.
tests/test_casting.py New test file with unit tests for casting functions, covering various input types and edge cases.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ConfigLoader
    participant _casting

    User->>ConfigLoader: load()
    ConfigLoader->>_casting: cast_value(str_value)
    _casting-->>ConfigLoader: casted_value
    ConfigLoader-->>User: config_dict with casted values
Loading
sequenceDiagram
    participant User
    participant ArgParser
    participant _casting

    User->>ArgParser: parse_task_args(input_args)
    ArgParser->>_casting: cast_value(arg)
    _casting-->>ArgParser: casted_arg
    ArgParser-->>User: args, kwargs (with casted values)
Loading

Poem

In the meadow of code, where strings used to stay,
Now casting arrives, whisking type woes away.
Bools, ints, and floats, all snug in their bed,
No more “true” as a string, but a real bool instead!
🐇✨
With tests all a-hopping, our types are just right—
The casting is magic, from morning till night!

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@exequielrafaela exequielrafaela added enhancement New feature or request patch labels Jun 5, 2025
@exequielrafaela exequielrafaela changed the title Implement typed argument casting Enhancement | Issue #21 | OPT-2 | Implement typed argument casting Jun 5, 2025
@coveralls
Copy link
Collaborator

Pull Request Test Coverage Report for Build 15472282000

Details

  • 30 of 32 (93.75%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall first build on bzbyrm-codex/review-issue-#21-and-propose-solution at 61.435%

Changes Missing Coverage Covered Lines Changed/Added Lines %
leverage/_casting.py 25 27 92.59%
Totals Coverage Status
Change from base Build 15417024595: 61.4%
Covered Lines: 2630
Relevant Lines: 4150

💛 - Coveralls

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
leverage/_casting.py (1)

1-8: Consider adding more comprehensive docstring and imports.

The module could benefit from a more detailed docstring explaining the casting strategy and potential edge cases.

 """
-Value casting utilities.
+Value casting utilities for converting string values to Python primitives.
+
+This module provides functions to safely cast string values to boolean, integer,
+and float types, falling back to the original string if casting fails.
 """
 
-from typing import Any
+from typing import Any, Union
 
 import yaml
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a4609c6 and 58aaf0e.

📒 Files selected for processing (6)
  • leverage/_casting.py (1 hunks)
  • leverage/_parsing.py (2 hunks)
  • leverage/conf.py (2 hunks)
  • tests/test__parsing.py (1 hunks)
  • tests/test_casting.py (1 hunks)
  • tests/test_conf.py (1 hunks)
🧰 Additional context used
🪛 Pylint (3.3.7)
tests/test__parsing.py

[refactor] 35-35: Redundant comparison - expected != expected

(R0124)


[refactor] 36-36: Redundant comparison - received != received

(R0124)

tests/test_casting.py

[refactor] 1-1: Useless option value for '--disable', 'print-statement' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'parameter-unpacking' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'unpacking-in-except' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'old-raise-syntax' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'backtick' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'import-star-module-level' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'apply-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'basestring-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'buffer-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'cmp-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'coerce-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'execfile-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'file-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'long-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'raw_input-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'reduce-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'standarderror-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'unicode-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'xrange-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'coerce-method' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'delslice-method' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'getslice-method' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'setslice-method' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'no-absolute-import' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'old-division' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'dict-iter-method' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'dict-view-method' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'next-method-called' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'metaclass-assignment' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'indexing-exception' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'raising-string' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'reload-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'oct-method' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'hex-method' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'nonzero-method' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'cmp-method' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'input-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'round-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'intern-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'unichr-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'map-builtin-not-iterating' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'zip-builtin-not-iterating' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'range-builtin-not-iterating' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'filter-builtin-not-iterating' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'using-cmp-argument' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'div-method' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'idiv-method' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'rdiv-method' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'exception-message-attribute' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'invalid-str-codec' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'sys-max-int' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'bad-python3-import' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'deprecated-string-function' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'deprecated-str-translate-call' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'deprecated-itertools-function' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'deprecated-types-field' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'next-method-defined' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'dict-items-not-iterating' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'dict-keys-not-iterating' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'dict-values-not-iterating' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'deprecated-operator-function' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'deprecated-urllib-function' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'xreadlines-attribute' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'deprecated-sys-function' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'exception-escape' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'comprehension-escape' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)

🪛 GitHub Actions: Tests | Lint w/ Black
tests/test__parsing.py

[error] 1-1: Prettier formatting check failed. Run 'black --write' to fix code style issues in this file.

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: integration_tests_cli_refarch (3.9.15, 1.3.5-0.2.0)
🔇 Additional comments (15)
tests/test_conf.py (1)

35-35:

❓ Verification inconclusive

Verify boolean casting behavior aligns with expectations.

Similar to MFA_ENABLED, the test now expects True instead of "true" for DEBUG. Ensure this type change is compatible with all code that consumes this configuration value.


🏁 Script executed:

#!/bin/bash
# Description: Search for usages of DEBUG to verify impact of type change

# Search for DEBUG usage patterns
rg -A 3 -B 3 "DEBUG"

Length of output: 3767


🏁 Script executed:

#!/bin/bash
# Locate configuration files
find . -type f | grep -E '/conf.*\.py$' || echo "no conf file"

Length of output: 130


🏁 Script executed:

#!/bin/bash
# Show definitions of MFA_ENABLED and DEBUG in leverage/conf.py
rg -n -C5 'MFA_ENABLED' leverage/conf.py
rg -n -C5 'DEBUG' leverage/conf.py

Length of output: 75


🏁 Script executed:

#!/bin/bash
# Show file leverage/conf.py with line numbers
cat -n leverage/conf.py

Length of output: 2295


ACTION REQUIRED: Confirm Boolean Casting Impact on DEBUG Consumption
The test now asserts "DEBUG": True (Python bool) instead of the string "true". Before merging, please verify that every consumer of the DEBUG config value handles a boolean rather than a string:

• leverage/conf.py → uses cast_value(val) to convert "true"True.
• Search codebase for config["DEBUG"] or .get("DEBUG") to ensure it’s not compared against strings.
• In leverage/logger.py, log‐level selection is driven by click's state.verbosity, not this DEBUG key—no direct impact there.
• Any other places that read the raw env var (e.g., manual os.getenv("DEBUG") checks) must expect a bool now.

Please review and update any string comparisons or downstream logic accordingly.

leverage/conf.py (2)

9-9: Import looks good.

Clean import of the casting functionality.


61-61: Casting integration implemented correctly.

The casting is applied appropriately to environment variable values. However, consider the performance impact if there are many environment variables, as each value now goes through the casting pipeline.

Note: The TODO comment on line 39 about returning an Env object for type casting utilities is now partially addressed by this implementation, though it still uses a dictionary.

leverage/_parsing.py (3)

5-5: Import looks good.

Clean import of the casting functionality.


45-45: Casting applied correctly to positional arguments.

The casting ensures that positional arguments are converted to appropriate types rather than remaining as strings.


52-52: Casting applied correctly to keyword arguments.

The casting ensures that keyword argument values are converted to appropriate types rather than remaining as strings.

tests/test__parsing.py (5)

11-11: LGTM: Proper casting verification for positional arguments.

The test case correctly expects integer and float casting instead of string values, aligning with the new casting functionality.


13-16: LGTM: Comprehensive keyword argument casting tests.

The test properly verifies that boolean and integer values are cast while preserving string values that shouldn't be cast.


18-28: Excellent edge case coverage for casting functionality.

The comprehensive test cases cover:

  • Scientific notation (1e10)
  • Special float values (inf, nan)
  • Leading zeros (007, 0123)
  • Boolean variations in different cases
  • Mixed keyword argument types

This ensures robust validation of the casting implementation.


34-38: Correct NaN handling implementation.

The element-wise comparison with special NaN handling is the proper approach since NaN != NaN evaluates to True in Python. The static analysis warning about redundant comparisons is a false positive in this context.

🧰 Tools
🪛 Pylint (3.3.7)

[refactor] 35-35: Redundant comparison - expected != expected

(R0124)


[refactor] 36-36: Redundant comparison - received != received

(R0124)


1-61:

❓ Verification inconclusive

Fix code formatting to resolve pipeline failure.

The Black formatter requires formatting fixes.


🏁 Script executed:

#!/bin/bash
# Description: Apply Black formatting to fix the pipeline failure
# Expected: File will be reformatted according to Black standards

black --check tests/test__parsing.py || echo "Formatting needed"
black --write tests/test__parsing.py

Length of output: 314


Formatting Check Required

Black could not be executed in this environment, so we’re unable to verify the formatting automatically. Please ensure that tests/test__parsing.py is formatted according to Black’s rules to fix the pipeline failure. For example:

pip install black
black tests/test__parsing.py
🧰 Tools
🪛 Pylint (3.3.7)

[refactor] 1-1: Useless option value for '--disable', 'print-statement' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'parameter-unpacking' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'unpacking-in-except' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'old-raise-syntax' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'backtick' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'import-star-module-level' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'apply-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'basestring-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'buffer-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'cmp-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'coerce-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'execfile-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'file-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'long-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'raw_input-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'reduce-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'standarderror-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'unicode-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'xrange-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'coerce-method' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'delslice-method' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'getslice-method' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'setslice-method' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'no-absolute-import' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'old-division' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'dict-iter-method' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'dict-view-method' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'next-method-called' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'metaclass-assignment' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'indexing-exception' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'raising-string' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'reload-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'oct-method' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'hex-method' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'nonzero-method' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'cmp-method' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'input-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'round-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'intern-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'unichr-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'map-builtin-not-iterating' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'zip-builtin-not-iterating' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'range-builtin-not-iterating' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'filter-builtin-not-iterating' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'using-cmp-argument' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'div-method' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'idiv-method' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'rdiv-method' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'exception-message-attribute' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'invalid-str-codec' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'sys-max-int' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'bad-python3-import' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'deprecated-string-function' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'deprecated-str-translate-call' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'deprecated-itertools-function' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'deprecated-types-field' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'next-method-defined' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'dict-items-not-iterating' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'dict-keys-not-iterating' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'dict-values-not-iterating' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'deprecated-operator-function' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'deprecated-urllib-function' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'xreadlines-attribute' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'deprecated-sys-function' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'exception-escape' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'comprehension-escape' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 35-35: Redundant comparison - expected != expected

(R0124)


[refactor] 36-36: Redundant comparison - received != received

(R0124)

🪛 GitHub Actions: Tests | Lint w/ Black

[error] 1-1: Prettier formatting check failed. Run 'black --write' to fix code style issues in this file.

tests/test_casting.py (4)

1-6: Clean imports and setup.

Proper imports for the testing framework and the casting module being tested.

🧰 Tools
🪛 Pylint (3.3.7)

[refactor] 1-1: Useless option value for '--disable', 'print-statement' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'parameter-unpacking' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'unpacking-in-except' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'old-raise-syntax' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'backtick' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'import-star-module-level' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'apply-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'basestring-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'buffer-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'cmp-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'coerce-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'execfile-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'file-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'long-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'raw_input-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'reduce-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'standarderror-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'unicode-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'xrange-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'coerce-method' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'delslice-method' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'getslice-method' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'setslice-method' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'no-absolute-import' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'old-division' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'dict-iter-method' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'dict-view-method' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'next-method-called' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'metaclass-assignment' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'indexing-exception' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'raising-string' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'reload-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'oct-method' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'hex-method' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'nonzero-method' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'cmp-method' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'input-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'round-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'intern-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'unichr-builtin' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'map-builtin-not-iterating' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'zip-builtin-not-iterating' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'range-builtin-not-iterating' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'filter-builtin-not-iterating' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'using-cmp-argument' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'div-method' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'idiv-method' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'rdiv-method' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'exception-message-attribute' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'invalid-str-codec' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'sys-max-int' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'bad-python3-import' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'deprecated-string-function' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'deprecated-str-translate-call' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'deprecated-itertools-function' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'deprecated-types-field' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'next-method-defined' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'dict-items-not-iterating' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'dict-keys-not-iterating' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'dict-values-not-iterating' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'deprecated-operator-function' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'deprecated-urllib-function' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'xreadlines-attribute' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'deprecated-sys-function' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'exception-escape' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


[refactor] 1-1: Useless option value for '--disable', 'comprehension-escape' was removed from pylint, see pylint-dev/pylint#4942.

(R0022)


8-23: Comprehensive parametrized test data for cast_value.

Excellent coverage including:

  • Boolean values ("true", "False")
  • Integers with edge cases ("-2", "007", "0123")
  • Floats with scientific notation ("1e3")
  • Special values ("inf", "nan")
  • Non-convertible strings ("foo")

This ensures thorough validation of the casting logic.


24-30: Proper NaN handling in assertions.

Using math.isnan() for NaN comparisons is the correct approach, avoiding the pitfall of direct NaN equality checks.


32-38: Good coverage of helper functions.

The tests verify both successful conversions and fallback behavior when conversion isn't possible, ensuring the helper functions work as expected.

Comment on lines +10 to +18
def as_bool(value: str) -> Any:
"""Return the boolean representation of ``value`` if possible."""
try:
parsed = yaml.safe_load(value)
if isinstance(parsed, bool):
return parsed
except yaml.YAMLError:
pass
return value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Security concern: yaml.safe_load can parse more than just booleans.

Using yaml.safe_load for boolean parsing is risky as it can interpret various YAML constructs beyond simple boolean values. This could lead to unexpected behavior or security issues.

Consider using a more explicit boolean parsing approach:

-def as_bool(value: str) -> Any:
-    """Return the boolean representation of ``value`` if possible."""
-    try:
-        parsed = yaml.safe_load(value)
-        if isinstance(parsed, bool):
-            return parsed
-    except yaml.YAMLError:
-        pass
-    return value
+def as_bool(value: str) -> Any:
+    """Return the boolean representation of ``value`` if possible."""
+    lower_value = value.lower().strip()
+    if lower_value in ('true', 'yes', '1', 'on'):
+        return True
+    elif lower_value in ('false', 'no', '0', 'off'):
+        return False
+    return value
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
def as_bool(value: str) -> Any:
"""Return the boolean representation of ``value`` if possible."""
try:
parsed = yaml.safe_load(value)
if isinstance(parsed, bool):
return parsed
except yaml.YAMLError:
pass
return value
def as_bool(value: str) -> Any:
"""Return the boolean representation of ``value`` if possible."""
lower_value = value.lower().strip()
if lower_value in ('true', 'yes', '1', 'on'):
return True
elif lower_value in ('false', 'no', '0', 'off'):
return False
return value
🤖 Prompt for AI Agents
In leverage/_casting.py around lines 10 to 18, the use of yaml.safe_load to
parse booleans is insecure because it can interpret complex YAML structures
beyond simple booleans. Replace yaml.safe_load with a more explicit boolean
parsing method that only recognizes specific string values like "true", "false",
"yes", "no" (case-insensitive) and returns the corresponding boolean, otherwise
return the original value.

Comment on lines +37 to +53
def cast_value(value: str) -> Any:
"""Try to cast ``value`` to bool, int or float using the helper functions
:func:`as_bool`, :func:`as_int` and :func:`as_float`.
Args:
value (str): Value to cast.
Returns:
Any: The value converted to its apparent type or the original string.
"""
value = as_bool(value)
if isinstance(value, str):
value = as_int(value)
if isinstance(value, str):
value = as_float(value)

return value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add input validation and improve type safety.

The function accepts str type but doesn't validate the input. Also, the casting order could cause issues where numeric strings like "123.0" are cast as integers instead of floats.

 def cast_value(value: str) -> Any:
-    """Try to cast ``value`` to bool, int or float using the helper functions
-    :func:`as_bool`, :func:`as_int` and :func:`as_float`.
-
-    Args:
-        value (str): Value to cast.
-
-    Returns:
-        Any: The value converted to its apparent type or the original string.
-    """
+    """Try to cast ``value`` to bool, int or float using the helper functions
+    :func:`as_bool`, :func:`as_int` and :func:`as_float`.
+
+    Args:
+        value (str): Value to cast.
+
+    Returns:
+        Any: The value converted to its apparent type or the original string.
+    """
+    if not isinstance(value, str):
+        return value
+        
     value = as_bool(value)
     if isinstance(value, str):
+        # Try float before int to handle decimal numbers correctly
+        temp_float = as_float(value)
+        if not isinstance(temp_float, str):
+            # Check if it's actually an integer value
+            if temp_float.is_integer():
+                return int(temp_float)
+            return temp_float
         value = as_int(value)
-    if isinstance(value, str):
-        value = as_float(value)
 
     return value
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
def cast_value(value: str) -> Any:
"""Try to cast ``value`` to bool, int or float using the helper functions
:func:`as_bool`, :func:`as_int` and :func:`as_float`.
Args:
value (str): Value to cast.
Returns:
Any: The value converted to its apparent type or the original string.
"""
value = as_bool(value)
if isinstance(value, str):
value = as_int(value)
if isinstance(value, str):
value = as_float(value)
return value
def cast_value(value: str) -> Any:
"""Try to cast ``value`` to bool, int or float using the helper functions
:func:`as_bool`, :func:`as_int` and :func:`as_float`.
Args:
value (str): Value to cast.
Returns:
Any: The value converted to its apparent type or the original string.
"""
if not isinstance(value, str):
return value
value = as_bool(value)
if isinstance(value, str):
# Try float before int to handle decimal numbers correctly
temp_float = as_float(value)
if not isinstance(temp_float, str):
# Check if it's actually an integer value
if temp_float.is_integer():
return int(temp_float)
return temp_float
value = as_int(value)
return value
🤖 Prompt for AI Agents
In leverage/_casting.py around lines 37 to 53, add input validation to ensure
the input is a string before processing to improve type safety. Adjust the
casting order to first attempt casting to float, then int, and finally bool, to
correctly handle numeric strings like "123.0" without prematurely casting them
as integers. Update the function to raise a TypeError if the input is not a
string.

@@ -30,9 +30,9 @@
True,
{
"PROJECT": "foobar",
"MFA_ENABLED": "true",
"MFA_ENABLED": True,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Verify boolean casting behavior aligns with expectations.

The test now expects True instead of "true" for MFA_ENABLED. This change aligns with the new casting functionality, but ensure this behavioral change is intentional and won't break downstream code that expects string values.


🏁 Script executed:

#!/bin/bash
# Description: Search for usages of MFA_ENABLED to verify impact of type change

# Search for MFA_ENABLED usage patterns
rg -A 3 -B 3 "MFA_ENABLED"

Length of output: 2238


Ensure consistent boolean conversion for MFA_ENABLED across modules.

Tests in tests/test_conf.py now expect native booleans, but downstream code still treats MFA_ENABLED as a string:

  • tests/test_modules/test_credentials.py fixture uses "MFA_ENABLED": "true" instead of True.
  • leverage/container.py does self.env_conf.get("MFA_ENABLED", "false") == "true" and has a # TODO: Convert values to bool upon loading.
  • leverage/modules/credentials.py assigns config_values["mfa_enabled"] directly from the raw string returned by env_config.get("MFA_ENABLED", "false").

Please update these places to use the new casting logic (returning booleans) and adjust the corresponding tests to expect True/False.

🤖 Prompt for AI Agents
In tests/test_conf.py at line 33, the MFA_ENABLED value is changed to a boolean
True, but related code in tests/test_modules/test_credentials.py,
leverage/container.py, and leverage/modules/credentials.py still treat
MFA_ENABLED as a string. Update these files to consistently use boolean values
for MFA_ENABLED by applying the new casting logic that converts environment
variables to booleans, and modify their tests to expect True/False instead of
"true"/"false" strings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
codex enhancement New feature or request patch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants