Skip to content

Single letter classnames wrongly cause C0103 (invalid-name) #3324

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
Starwort opened this issue Dec 29, 2019 · 5 comments
Closed

Single letter classnames wrongly cause C0103 (invalid-name) #3324

Starwort opened this issue Dec 29, 2019 · 5 comments
Labels
Duplicate 🐫 Duplicate of an already existing issue

Comments

@Starwort
Copy link

Steps to reproduce

  1. from typing import TypeVar
  2. T = TypeVar('T')
  3. C0103: Class name "T" doesn't conform to PascalCase naming style (invalid-name)

Current behaviour

C0103: Class name "T" doesn't conform to PascalCase naming style (invalid-name)

Expected behaviour

no C0103

pylint --version output

pylint 2.4.3
astroid 2.3.1
Python 3.8.0 (default, Oct 15 2019, 14:05:58)
[GCC 7.4.0]

@PCManticore
Copy link
Contributor

This is a duplicate of #2018. The issue is that the naming styles need at least 3 characters by default so T fails the check since it is too short. You can check that yourself by passing --include-naming-hint=y which will show the regular expression against which the name is validated.

@PCManticore PCManticore added the Duplicate 🐫 Duplicate of an already existing issue label Dec 30, 2019
@phiresky
Copy link

phiresky commented Feb 8, 2022

It would be good if there was a way to make pylint recognize this correctly as a type variable instead of a "class name", since the usual convention for type variables is to be single-letter (as opposed to class names).

I don't want to disable the lint for real class names, but I do want to disable it for type vars.

@DanielNoord
Copy link
Collaborator

We're working on this in #5221. It (hopefully) will be part of the next version!

@phiresky
Copy link

phiresky commented Feb 8, 2022

Great! I guess this issue is really a dupe of #3401 then instead of #2018 (referencing since I found only this one via google)

@DanielNoord
Copy link
Collaborator

You're right! Thanks for pointing that out 😄

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Duplicate 🐫 Duplicate of an already existing issue
Projects
None yet
Development

No branches or pull requests

4 participants