From 6da52ac411947d1a7958bbad831fcf8dfc8c95fe Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Sun, 13 Oct 2019 05:04:05 -0700 Subject: bpo-38431: Fix __repr__ method of InitVar to work with typing objects. (GH-16702) (cherry picked from commit 793cb85437299a3da3d74fe65480d720af330cbb) Co-authored-by: Samuel Colvin --- Lib/dataclasses.py | 7 ++++++- Lib/test/test_dataclasses.py | 2 ++ Misc/NEWS.d/next/Library/2019-10-10-16-53-00.bpo-38431.d5wzNp.rst | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Library/2019-10-10-16-53-00.bpo-38431.d5wzNp.rst diff --git a/Lib/dataclasses.py b/Lib/dataclasses.py index 2f0e5ff..391f32e 100644 --- a/Lib/dataclasses.py +++ b/Lib/dataclasses.py @@ -210,7 +210,12 @@ class InitVar(metaclass=_InitVarMeta): self.type = type def __repr__(self): - return f'dataclasses.InitVar[{self.type.__name__}]' + if isinstance(self.type, type): + type_name = self.type.__name__ + else: + # typing objects, e.g. List[int] + type_name = repr(self.type) + return f'dataclasses.InitVar[{type_name}]' # Instances of Field are only ever created from within this module, diff --git a/Lib/test/test_dataclasses.py b/Lib/test/test_dataclasses.py index 0885c97..b018133 100755 --- a/Lib/test/test_dataclasses.py +++ b/Lib/test/test_dataclasses.py @@ -1102,6 +1102,8 @@ class TestCase(unittest.TestCase): # Make sure the repr is correct. self.assertEqual(repr(InitVar[int]), 'dataclasses.InitVar[int]') + self.assertEqual(repr(InitVar[List[int]]), + 'dataclasses.InitVar[typing.List[int]]') def test_init_var_inheritance(self): # Note that this deliberately tests that a dataclass need not diff --git a/Misc/NEWS.d/next/Library/2019-10-10-16-53-00.bpo-38431.d5wzNp.rst b/Misc/NEWS.d/next/Library/2019-10-10-16-53-00.bpo-38431.d5wzNp.rst new file mode 100644 index 0000000..c2f860d --- /dev/null +++ b/Misc/NEWS.d/next/Library/2019-10-10-16-53-00.bpo-38431.d5wzNp.rst @@ -0,0 +1 @@ +Fix ``__repr__`` method for :class:`dataclasses.InitVar` to support typing objects, patch by Samuel Colvin. -- cgit v0.12 option> Tcl is a high-level, general-purpose, interpreted, dynamic programming language. It was designed with the goal of being very simple but powerful.
summaryrefslogtreecommitdiffstats
path: root/unix/tclLoadOSF.c
Commit message (Expand)AuthorAgeFilesLines
* load fixes for Bug 611108vincentdarley2002-10-101-2/+22
* Tcl_LoadHandle usagevincentdarley2002-07-181-4/+4
* load comments and clientData replacementvincentdarley2002-07-181-10/+22
* load internals refactoringvincentdarley2002-07-171-15/+18
* Updated APIs in the files */tcl*Load*.c according to the guidelinesKevin B Kenny2002-01-091-2/+2
* * More CONST poisoningdgp2001-09-281-2/+2
* minor fs, vfs fixesvincentdarley2001-09-041-3/+9
* filesystemvincentdarley2001-08-301-4/+5
* merged tcl 8.1 branch back into the main trunkstanton1999-04-161-5/+37
* Replaced SCCS strings, fixed binary filescore_8_0_3stanton1998-09-141-1/+1
* Initial revisionrjohnson1998-03-261-0/+128