python27-type-annotations

Adds parser-friendly # type: comments to Python 2.7 code for IDE completion.

Updated Apr 11, 2026
One-click install
npx skills add https://github.com/Coral5644/NekansModPack --skill python27-type-annotations-coral5644
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: python27-type-annotations
Source: https://github.com/Coral5644/NekansModPack/tree/main/.cursor/skills/python27-type-annotations
Command: npx skills add https://github.com/Coral5644/NekansModPack --skill python27-type-annotations-coral5644

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Python 2.7 code cannot use Python 3 inline annotations, so IDEs and static analyzers like pyright often lose track of variable types, breaking method completion, navigation, and highlighting. This Skill restores type visibility by adding parser-friendly # type: comments without importing typing into runtime code. ## Core Features & Use Cases - Targeted Annotation Placement: Annotates function signatures, instance attributes, factory/lookup results, containers, for loop sources, unpacking variables, callbacks, and chained-call intermediate variables. - Safe Cross-Module Type Imports: Uses if 1 > 2: guarded imports so editors can resolve types from other modules while runtime never executes them. - Concrete-Type Enforcement: Forbids annotating class instances as object and discourages Optional, favoring early returns, state flags, and deferred assignment. - Use Case: When self.screen.GetBaseUIControl(path).asImage() breaks completion, split the chain into named variables, annotate each with a concrete # type: comment, and verify method completion recovers on the next line. ## Quick Start Ask the assistant to add Python 2.7 compatible # type: comments to the variables and functions in this file so IDE method completion works again.

Frequently Asked Questions about python27-type-annotations

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add type hints to Python 2.7 code?▼

Use `# type:` comments instead of Python 3 inline annotations. Annotate function signatures as `# type: (A, B) -> C` and place variable annotations at the end of the assignment line, such as `items = [] # type: list[Item]`.

How do I fix IDE autocomplete not working in Python 2.7?▼

Autocomplete fails when the parser cannot infer a variable's type. Add explicit `# type:` comments to instances, containers, and factory results, split chained calls into named variables, and verify completion recovers on the following line.

Can I use the typing module in Python 2.7 runtime code?▼

No, this approach forbids importing typing into runtime code and avoids typing.Optional, typing.Union, and typing.List. Express nullable values with early returns, state flags, or deferred assignment instead.

How do I annotate types imported from another module without runtime cost?▼

Wrap the import in an `if 1 > 2:` block so editors can resolve the type while the interpreter never executes it. Then reference the imported class normally in `# type:` comments.

Why is annotating a variable as object a problem?▼

Annotating a class instance as `object` tells the editor nothing about its methods, so completion and navigation stop working. Always annotate with the concrete class type so subsequent method calls resolve correctly.

When should I use a syntax reviewer instead of type annotations?▼

If the problem is purely Python 2.7 syntax compatibility, use a syntax review skill first. Use type annotations only when variables lack explicit types and the parser fails to resolve subsequent method calls.