Skip to content

[FEATURE]: Python: Spell check import alias names #185

@0xaaadnf

Description

@0xaaadnf

Feature Description

Currently, the spell checker ignores Python import alias names.
For example:

import numpy as npy

The alias name npy is not checked. I propose enabling spell checking for alias names,
because, unlike regular import names, they are defined by the user.
Regular import names remain ignored, as they are outside user control.

This change would allow the LSP server to detect potential typos in user-defined aliases.

Use Case

Alias names in Python are fully controlled by the developer. Currently, the spell checker misses typos in these user-defined names.

Proposed Solution

Update the Tree-sitter queries to capture alias names in both import x as y and from module import x as y statements.

Alternative Solutions

No response

Examples

No response

Additional Context

Editor preview after enabling spell checking for alias names:

# Regular import names, ignored
import no_typpoa
import no_typpob.no_typpoc

# Alias names, now captured by spell checker
import no_typpod as yes_typpoe     #■ Possible spelling issue 'typpoe'. (source=Codebook)
import no_typpof.no_typpog as yes_typpoh     #■ Possible spelling issue 'typpoh'. (source=Codebook)

# From-import statements, regular names ignored
from no_typpoi import no_typpoj
from no_typpok.no_typpol import no_typpom

# Alias names captured
from no_typpoo import no_typpop as yes_typpoq     #■ Possible spelling issue 'typpoq'. (source=Codebook)
from no_typpor.no_typpos import no_typpot as yes_typpou     #■ Possible spelling issue 'typpou'. (source=Codebook)
from .. import no_typpov as yes_typpow     #■ Possible spelling issue 'typpow'. (source=Codebook)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions