From 158dc1aeab8760ec6e6afe2b43a72dbe4dbeccfd Mon Sep 17 00:00:00 2001
From: Petr
Date: Fri, 6 Dec 2024 13:56:33 +0100
Subject: [PATCH] PY-76842 Conformance test failure: aliases_newtype.py
NewType's type argument check.
GitOrigin-RevId: f4c2c6fc61b604458cb6182f1e4db7f8f53f2087
---
.../PyNewTypeInspection.html | 19 ++++++++++-----
.../resources/messages/PyPsiBundle.properties | 5 +++-
.../python/inspections/PyNewTypeInspection.kt | 24 +++++++++++++++++++
.../inspections/PyNewTypeInspectionTest.kt | 23 ++++++++++++++++++
4 files changed, 64 insertions(+), 7 deletions(-)
diff --git a/python/python-psi-impl/resources/inspectionDescriptions/PyNewTypeInspection.html b/python/python-psi-impl/resources/inspectionDescriptions/PyNewTypeInspection.html
index b3e8f05dff56..8f917efdb93c 100644
--- a/python/python-psi-impl/resources/inspectionDescriptions/PyNewTypeInspection.html
+++ b/python/python-psi-impl/resources/inspectionDescriptions/PyNewTypeInspection.html
@@ -4,16 +4,23 @@
Reports invalid usages of NewType.
- Example:
+ Examples:
-from typing import NewType
+ from typing import NewType
-Base = NewType("Base", str)
-A = NewType("B", int) # Variable name 'A' does not match NewType name 'B'
+ InvalidName = NewType("Name", int) # Variable name 'InvalidName' does not match NewType name 'Name'
+
+
+ from typing import Literal
-class Derived(Base): # 'Base' cannot be subclassed
- pass
+ InvalidType = NewType("InvalidType", Literal[1]) # NewType cannot be used with 'Literal[1]'
+
+
+ Base = NewType("Base", str)
+
+ class Derived(Base): # 'Base' cannot be subclassed
+ pass