Skip to content

Use ABC base class#536

Merged
phiwuu merged 2 commits intomainfrom
internal/use-abc
Feb 19, 2026
Merged

Use ABC base class#536
phiwuu merged 2 commits intomainfrom
internal/use-abc

Conversation

@phiwuu
Copy link
Member

@phiwuu phiwuu commented Feb 18, 2026

The main goal of this pull request is to resolve the pylint warning too-few-public-methods.

Please consider the following:

  1. checkout main branch
  2. remove too-few-public-methods from
    too-few-public-methods,
  3. call make lint and remember the output
  4. checkout the branch internal/use-abc of this PR, and repeat steps 2 and 3

The errors in file htmldoc.py will disappear.

The following changes are necessary to make pylint happy:
The base class Menu_Item had a statement assert false, which is a code smell. In order to remove this, the class now inherits from ABC and the generate method is an abstract method.

Also removed those assert statements which verified only the type. At the beginning of the project these assertions had been used to develop a reliable implementation in the sense of ISO 26262, but the (ongoing) tool qualification efforts allow to follow Python's duck typing philosophy again.

@phiwuu phiwuu requested a review from a team as a code owner February 18, 2026 03:54
@phiwuu phiwuu added the internal Affects the CI, tests or refactorings only, not relevant to the end-user label Feb 18, 2026
@phiwuu phiwuu enabled auto-merge (squash) February 18, 2026 03:56
anchor: Optional[str] = None,
html_identifier: bool = False,
):
assert 2 <= level <= 7
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of assert here we can add a check and raise an error

Copy link
Member Author

@phiwuu phiwuu Feb 18, 2026

Choose a reason for hiding this comment

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

Yes, that's true. But I wanted to keep the refactoring minimal. Raising an exception basically means a new code path, which should be tested by a unit test. There is another assertion of this kind: assert alignment in ("left", "right")
I recommend to do this in a separate pull request.

The main goal of this pull request is to resolve the pylint warning too-few-public-methods. Please do the following:

  1. checkout main branch
  2. remove too-few-public-methods from
    too-few-public-methods,
  3. call make lint, and remember the output
  4. checkout the branch internal/use-abc of this PR, and repeat steps 2 and 3

The errors in file htmldoc.py will disappear. I should have made this clear from the beginning in the PR description. I will update it accordingly.

I removed the assert statements only as a clean-up side-task. Please approve the PR without further changes. Thank you!

The base class `Menu_Item` had a statement `assert false`,
which is a code smell. In order to remove this, the class
now inherits from `ABC` and the `generate` method is an
abstract method.
Removed those `assert` statements which verified only the type.
At the beginning of the project these assertions had been used to
develop a reliable implementation in the sense of ISO 26262,
but the (ongoing) tool qualification efforts allow to follow
Python's duck typing philosophy again.
@phiwuu phiwuu merged commit 578f210 into main Feb 19, 2026
23 checks passed
@phiwuu phiwuu deleted the internal/use-abc branch February 19, 2026 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal Affects the CI, tests or refactorings only, not relevant to the end-user

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants