Skip to content

changes according to Issue 451#457

Merged
tomaae merged 1 commit into
tomaae:masterfrom
Fischelsberger:fix_451
Jan 12, 2026
Merged

changes according to Issue 451#457
tomaae merged 1 commit into
tomaae:masterfrom
Fischelsberger:fix_451

Conversation

@Fischelsberger
Copy link
Copy Markdown

@Fischelsberger Fischelsberger commented Jan 12, 2026

Proposed change

Implemented changes by @jackomm in #451

I don't understand addition of super().__init__(), it worked w/o that in my test too.

Type of change

  • Bugfix
  • New feature
  • Code quality improvements to existing code or addition of tests
  • Documentation

Additional information

Checklist

  • The code change is tested and works locally.
  • The code has been formatted using Black.
  • Tests have been added to verify that the new code works.
  • Documentation added/updated if required.

Summary by Sourcery

Bug Fixes:

  • Ensure options flow reads defaults from the correct config entry attribute to prevent configuration errors in the Mikrotik integration.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Jan 12, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Refactors the Mikrotik options flow handler to consistently use the private _config_entry attribute instead of config_entry when reading config entry options for all option steps, aligning with the implementation from issue #451.

Class diagram for updated MikrotikControllerOptionsFlowHandler config entry usage

classDiagram
    class OptionsFlow

    class MikrotikControllerOptionsFlowHandler {
        - config_entry
        - _config_entry
        - options
        + MikrotikControllerOptionsFlowHandler(config_entry)
        + async_step_init(user_input)
        + async_step_basic_options(user_input)
        + async_step_sensor_select(user_input)
    }

    OptionsFlow <|-- MikrotikControllerOptionsFlowHandler

    %% Before change: MikrotikControllerOptionsFlowHandler used public config_entry
    %% After change: MikrotikControllerOptionsFlowHandler uses private _config_entry for all option defaults
Loading

File-Level Changes

Change Details Files
Use a private _config_entry attribute for the options flow handler and update all option schema defaults to reference it.
  • Rename the config_entry instance attribute in MikrotikControllerOptionsFlowHandler.__init__ to _config_entry.
  • Update all vol.Optional(..., default=...) definitions in async_step_basic_options to use _config_entry.options.get(...) for default values instead of config_entry.options.get(...).
  • Update all vol.Optional(..., default=...) definitions in async_step_sensor_select to use _config_entry.options.get(...) for default values instead of config_entry.options.get(...).
custom_components/mikrotik_router/config_flow.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

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • If _config_entry is meant to be an internal-only attribute, consider also renaming the constructor parameter to _config_entry or adding a short comment to clarify why this attribute was renamed from config_entry to avoid confusion for future maintainers.
  • Consider adding a type annotation to self._config_entry in __init__ (e.g., HomeAssistantType/ConfigEntry as appropriate) to make the purpose and expected shape of the stored config entry clearer for tooling and readers.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- If `_config_entry` is meant to be an internal-only attribute, consider also renaming the constructor parameter to `_config_entry` or adding a short comment to clarify why this attribute was renamed from `config_entry` to avoid confusion for future maintainers.
- Consider adding a type annotation to `self._config_entry` in `__init__` (e.g., `HomeAssistantType`/`ConfigEntry` as appropriate) to make the purpose and expected shape of the stored config entry clearer for tooling and readers.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@tomaae tomaae merged commit a5ae830 into tomaae:master Jan 12, 2026
7 of 8 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Jan 20, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants