Skip to content

meanmail-dev/PyAnnotations

Repository files navigation

PyAnnotations

JetBrains IntelliJ Plugins JetBrains IntelliJ plugins GitHub

Smart code inspections for Python type annotations — simplify, modernize, and validate your type hints with one-click quick fixes.

Features

21 Inspections with Quick Fixes

Union & Optional Simplification

Union[int, None]           →  Optional[int]
Union[X, object]           →  object
Union[X, Any]              →  Any
Union[dict]                →  dict
Optional[Optional[X]]      →  Optional[X]
Union[int, int, str]       →  Union[int, str]
Union[int, bool]           →  int  # bool is subtype of int
Union[Union[A, B], C]      →  Union[A, B, C]

Modern Pipe Syntax (Python 3.10+)

X | objectobject
X | AnyAny
(X | Y) | ZX | Y | Z
(X) | YX | Y

Syntax Conversion (disabled by default)

# Modernization (Python 3.10+)
Union[X, Y]                →  X | Y
Optional[X]                →  X | None

# Backward Compatibility (Python < 3.10)
X | YUnion[X, Y]
X | NoneOptional[X]

# PEP 585 (Python 3.9+)
List[int]                  →  list[int]
Dict[str, int]             →  dict[str, int]

# PEP 695 (Python 3.12+)
MyType: TypeAlias = int    →  type MyType = int

Advanced Inspections (disabled by default)

  • Missing Optional for parameters with None default
  • Simplify Callable[..., Any]Callable
  • Redundant Generic[T] in class definitions
  • Unbound TypeVar (used only once)
  • Protocol methods without type annotations

Installation

  1. Open Settings/PreferencesPluginsMarketplace
  2. Search for "Python Annotations"
  3. Click Install

Or install from JetBrains Marketplace

Supported IDEs

All JetBrains IDEs with Python support:

  • PyCharm (Community & Professional)
  • IntelliJ IDEA with Python plugin
  • Other JetBrains IDEs with Python plugin

Requires: IDE version 2025.2+

Configuration

All inspections can be configured in SettingsEditorInspectionsPython Annotations

  • Enable/disable individual inspections
  • Change severity levels (Error, Warning, Weak Warning)
  • Suppress for specific files or scopes

Contributing

Contributions are welcome! See ROADMAP.md for planned features.

License

Apache License 2.0

About

Plugin for JetBrains IDE: Code Inspections for Python Annotations

Topics

Resources

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Contributors 3

  •  
  •  
  •