Skip to content

Handle missing python-dotenv dependency in env loader - #1

Closed
ereezyy wants to merge 13 commits into
masterfrom
codex/find-and-fix-a-bug-in-codebase
Closed

Handle missing python-dotenv dependency in env loader#1
ereezyy wants to merge 13 commits into
masterfrom
codex/find-and-fix-a-bug-in-codebase

Conversation

@ereezyy

@ereezyy ereezyy commented Oct 31, 2025

Copy link
Copy Markdown
Owner

Summary

  • allow the environment loader to work when python-dotenv is not installed
  • log a clear message when skipping .env loading due to the optional dependency being absent

Testing

  • python - <<'PY' from AgentSystem.utils.env_loader import env; print('env loader path:', env.env_path) ; PY

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

Summary by Sourcery

Enhancements:

  • Gracefully handle missing python-dotenv dependency by providing a fallback import and skipping .env loading with an informative log message

@sourcery-ai

sourcery-ai Bot commented Oct 31, 2025

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR makes the python-dotenv dependency optional by wrapping its import in a try/except and adds a runtime check in the environment loader to skip and log loading when the dependency is missing.

Class diagram for updated env loader dependency handling

classDiagram
    class EnvLoader {
        -env_path: Path
        +_load_env_file(): None
    }
    EnvLoader : +_load_env_file() checks for python-dotenv
    EnvLoader : +_load_env_file() logs info if python-dotenv missing
    EnvLoader : +_load_env_file() loads .env if python-dotenv present
Loading

File-Level Changes

Change Details Files
Make python-dotenv import optional
  • Wrap import of load_dotenv in a try/except block
  • Assign load_dotenv to None on ModuleNotFoundError
AgentSystem/utils/env_loader.py
Skip .env loading when python-dotenv is absent
  • Add a check for load_dotenv being None in _load_env_file
  • Log an info message and return early if the dependency is missing
AgentSystem/utils/env_loader.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@ereezyy ereezyy self-assigned this Nov 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant