Skip to content

Remove deprecated mypy option#611

Open
jwhonce wants to merge 1 commit intocontainers:mainfrom
jwhonce:wip/mypy_deprecated_option
Open

Remove deprecated mypy option#611
jwhonce wants to merge 1 commit intocontainers:mainfrom
jwhonce:wip/mypy_deprecated_option

Conversation

@jwhonce
Copy link
Copy Markdown
Member

@jwhonce jwhonce commented Dec 16, 2025

  • "no_strict_optional = true" has been deprecated by mypy. This change removes linting errors.

Signed-off-by: Jhon Honce jhonce@redhat.com

@jwhonce jwhonce self-assigned this Dec 16, 2025
Copilot AI review requested due to automatic review settings December 16, 2025 17:39
@jwhonce jwhonce added the bug Something isn't working label Dec 16, 2025
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR removes the deprecated no_strict_optional = true option from the mypy configuration in pyproject.toml. The option has been deprecated by mypy and its removal eliminates linting errors.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@inknos
Copy link
Copy Markdown
Contributor

inknos commented Dec 16, 2025

/packit rebuild-failed

@inknos
Copy link
Copy Markdown
Contributor

inknos commented Dec 16, 2025

I didn't find the deprecation notice but since "it's evil" let's remove it and work on fixing the type checks

@Honny1
Copy link
Copy Markdown
Member

Honny1 commented Feb 5, 2026

It seems that disabling this option exposed several issues. I think we should address them.

PTAL @jwhonce

@jwhonce
Copy link
Copy Markdown
Member Author

jwhonce commented Mar 25, 2026

@inknos @Honny1 Please review now that tests pass.

Copy link
Copy Markdown
Member

@Honny1 Honny1 left a comment

Choose a reason for hiding this comment

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

I have some nits about ignoring errors. Otherwise LGTM.

* "no_strict_optional = true" has been deprecated by mypy. This change
  removes the option and fixes all resulting type-checking errors.

* podman/api/http_utils.py: Widen prepare_filters() signature to accept
  None and Mapping[str, Any], matching its runtime behavior. Resolves
  arg-type errors in volumes, quadlets, and networks_manager.

* podman/domain/containers_manager.py: Make prune() filters parameter
  explicitly Optional per PEP 484 (no_implicit_optional=True).

* podman/domain/containers_run.py: Use "command or []" when passing to
  ContainerError to handle the None case.

* podman/domain/volumes.py: Add assertion to narrow path type after
  validation guards for pathlib.Path() call.

* podman/tests/utils.py: Assert proc.stdout is not None before reading
  to narrow IO[bytes] | None type.

* podman/tests/integration/utils.py: Type podman_exe as Optional[str]
  since podman_path parameter can be None.

* podman/tests/integration/base.py: Type podman class variable as
  Optional[str] with import.

* podman/tests/unit/test_api_utils.py: Add dict[str, Any] annotation
  to payload variable.

Reviewer feedback:

* podman/client.py: Introduce api_version Optional[str] variable
  instead of using a type: ignore pragma on version = None.

* podman/domain/manager.py: Keep self.client honestly typed as
  Optional[APIClient]. Add an api property to both PodmanResource
  and Manager that narrows the type to APIClient, raising
  AttributeError if client is None.

* All domain modules (pods, volumes, secrets, quadlets, images,
  containers, networks, manifests, pods_manager, images_manager,
  images_build, containers_create, networks_manager,
  containers_manager): Use self.api instead of self.client for API
  calls to get proper type narrowing without pragmas.

* pyproject.toml: Consolidate ruff exclude into top-level [tool.ruff]
  section covering .history, _build, and other generated directories
  for both linting and formatting.

Signed-off-by: Jhon Honce <jhonce@redhat.com>
Made-with: Cursor
@jwhonce jwhonce force-pushed the wip/mypy_deprecated_option branch from 9b4a822 to 996dd51 Compare March 26, 2026 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants