Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Union type as second arg for isinstance raises W1116 #8381

Closed
hofrob opened this issue Mar 4, 2023 · 3 comments
Closed

Union type as second arg for isinstance raises W1116 #8381

hofrob opened this issue Mar 4, 2023 · 3 comments
Labels
Invalid Not a bug, already exists or already fixed
Milestone

Comments

@hofrob
Copy link
Contributor

hofrob commented Mar 4, 2023

Bug description

The following is valid code in python 3.10+ (iirc):

a = 1

isinstance(a, int | str)

Configuration

# default

Command used

pylint --score=n -d all -e W1116 foo.py

Pylint output

************* Module foo
foo.py:3:0: W1116: Second argument of isinstance is not a type (isinstance-second-argument-not-valid-type)

Expected behavior

No error

Pylint version

$ pylint --version
pylint 2.16.3
astroid 2.14.2
Python 3.11.2 (main, Feb  9 2023, 13:29:03) [GCC 11.3.0]

OS / Environment

Ubuntu 22.04

Additional dependencies

No response

@hofrob hofrob added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Mar 4, 2023
@hofrob
Copy link
Contributor Author

hofrob commented Mar 4, 2023

I just discovered this because ruff is rewriting isinstance(a, (int, str)) to union types since v0.0.254. It may be related to another issue, but I came up empty after looking at existing ones.

@nickdrozd
Copy link
Collaborator

Fixed with #8206. 2.17 maybe?

@Pierre-Sassoulas Pierre-Sassoulas added Invalid Not a bug, already exists or already fixed and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Mar 4, 2023
@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.17.0 milestone Mar 4, 2023
@Pierre-Sassoulas
Copy link
Member

We'll release 2.17 soon, we're only waiting for try star node support from astroid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Invalid Not a bug, already exists or already fixed
Projects
None yet
Development

No branches or pull requests

3 participants