Skip to content

TypeAlias not conforming to PascalCase to throw invalid-name #7081

@jamesbraza

Description

@jamesbraza

Current problem

Python typing.TypeAlias are an alias to a type (as we all know). Thus, I think TypeAlias should have to follow type naming conventions (e.g. PascalCase for classes, unless a primitive).

In other words, we should see TypeAlias really as not much different from a novel class in regards to naming conventions. I think pylint is the tool to help enforce this!

Desired solution

Please see the below code snippet

# pylint: disable=missing-module-docstring

from threading import Thread  # Placeholder class
from typing import TypeAlias

ThreadAlias: TypeAlias = Thread  # Say nothing here
THREAD_ALIAS: TypeAlias = Thread  # Throw invalid-name
# C0103: Type alias "THREAD_ALIAS" doesn't conform to PascalCase naming style (invalid-name)

To restate, I think pylint should error on CLASS_NAME_ALIAS with invalid-name.

Additional context

See the TypeAlias PEP: https://peps.python.org/pep-0613/#error-messaging

They use ClassName, not CLASS_NAME.

Metadata

Metadata

Assignees

Labels

C: invalid-nameEnhancement ✨Improvement to a componentNeeds PRThis issue is accepted, sufficiently specified and now needs an implementation

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions