Skip to content

chore: add 5 return type hints in completer.py#15159

Draft
travellingsoldier85 wants to merge 1 commit into
ipython:mainfrom
travellingsoldier85:auto-improve/type_hint/209aa0-202603170902
Draft

chore: add 5 return type hints in completer.py#15159
travellingsoldier85 wants to merge 1 commit into
ipython:mainfrom
travellingsoldier85:auto-improve/type_hint/209aa0-202603170902

Conversation

@travellingsoldier85

Copy link
Copy Markdown
Contributor

Summary

Added concrete return type annotations to functions in IPython/core/completer.py based on static analysis of return statements.

Changes

  • Add return type hint -> list to function
  • Add return type hint -> list to function
  • Add return type hint -> tuple to function
  • Add return type hint -> bool to function
  • Add return type hint -> list to function

Type of Change

  • Code quality improvement (type hints)
  • Bug fix
  • New feature

Motivation

These type annotations are inferred from actual return values in the function bodies (e.g. return True-> bool, return []-> list). They improve:

  • IDE autocompletion and type checking (mypy/pyright)
  • Code readability for contributors navigating the codebase
  • Bug prevention via static analysis

No functional changes — only type annotations added.

@Carreau

Carreau commented Mar 19, 2026

Copy link
Copy Markdown
Member

In general don't stop to just list, or tuple, those are generics, and you can/should say they are list[str], list[tuple[str,...]]`, or whatever, try to be specific for the types it returns.

@Carreau Carreau force-pushed the auto-improve/type_hint/209aa0-202603170902 branch from 8ee873f to 6155c34 Compare March 19, 2026 10:31
@Carreau

Carreau commented Mar 19, 2026

Copy link
Copy Markdown
Member

https://typing.python.org/en/latest/reference/generics.html for introduction on generics.

@themavik themavik left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit: bare list/tuple return annotations help little; if you are editing these, prefer list[str] or a concrete tuple type.

@Carreau Carreau marked this pull request as draft March 25, 2026 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants