From ca3d199fb024f81b3e622dc9d71a4b07eea5be30 Mon Sep 17 00:00:00 2001 From: Semyon Proshev Date: Fri, 17 Jun 2016 20:43:44 +0300 Subject: [PATCH] PY-19796 Fixed: Incorrect parameter type hint for ord() function parameter Update skeleton of ord function to accept bytes in Py3 --- python/helpers/python-skeletons/builtins.py | 2 +- python/testData/inspections/PyTypeCheckerInspection/Ord.py | 2 ++ .../python/inspections/Py3TypeCheckerInspectionTest.java | 5 +++++ 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 python/testData/inspections/PyTypeCheckerInspection/Ord.py diff --git a/python/helpers/python-skeletons/builtins.py b/python/helpers/python-skeletons/builtins.py index 627885385b70..edaccdeaec4c 100644 --- a/python/helpers/python-skeletons/builtins.py +++ b/python/helpers/python-skeletons/builtins.py @@ -250,7 +250,7 @@ def open(name, mode='r', buffering=-1, encoding=None, errors=None, newline=None, def ord(c): """Return the integer ordinal of a one-character string. - :type c: str + :type c: bytes | str :rtype: int """ return 0 diff --git a/python/testData/inspections/PyTypeCheckerInspection/Ord.py b/python/testData/inspections/PyTypeCheckerInspection/Ord.py new file mode 100644 index 000000000000..b24b68d2e02f --- /dev/null +++ b/python/testData/inspections/PyTypeCheckerInspection/Ord.py @@ -0,0 +1,2 @@ +ord(b'A') +ord('A') \ No newline at end of file diff --git a/python/testSrc/com/jetbrains/python/inspections/Py3TypeCheckerInspectionTest.java b/python/testSrc/com/jetbrains/python/inspections/Py3TypeCheckerInspectionTest.java index 9a0bebdd90e9..6a445ea842f0 100644 --- a/python/testSrc/com/jetbrains/python/inspections/Py3TypeCheckerInspectionTest.java +++ b/python/testSrc/com/jetbrains/python/inspections/Py3TypeCheckerInspectionTest.java @@ -108,4 +108,9 @@ public class Py3TypeCheckerInspectionTest extends PyTestCase { public void testListGetItemWithSlice() { doTest(); } + + // PY-19796 + public void testOrd() { + doTest(); + } }