[issue38401] Make dataclass attribute docstrings accessible
New submission from John Parejko : Dataclasses provide a very straightforward way to specify structured data. One can trivally document a dataclass's attributes via triple-quoted attribute docstrings per PEP 257. However, those docstrings are not accessible to pydoc, so they are lost to users of the dataclass. For example, the attribute docstrings in the below dataclass should be available when looking at `help(SpectralData)`, but that help command does not show the docstrings. ``` @dataclasses.dataclass class SpectralData: """Class to hold data and metadata from a fiber spectrograph.""" wavelength: astropy.units.Quantity """The wavelength array produced by the instrument.""" spectrum: np.ndarray """The flux array in instrumental units.""" duration: float """The duration of the exposure in seconds.""" ``` -- assignee: docs@python components: Documentation messages: 354154 nosy: John Parejko2, docs@python priority: normal severity: normal status: open title: Make dataclass attribute docstrings accessible type: enhancement ___ Python tracker <https://bugs.python.org/issue38401> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23078] unittest.mock patch autospec doesn't work on staticmethods
John Parejko added the comment: Adding to the list of "I just ran into this". The patch submitted by fov seems straightforward enough: what can we do to help shepherd it along? -- nosy: +John Parejko2 ___ Python tracker <https://bugs.python.org/issue23078> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23078] unittest.mock patch autospec doesn't work on staticmethods
John Parejko added the comment: Were you able to make any progress on this? Do you need any help? -- nosy: +parejkoj-3 ___ Python tracker <https://bugs.python.org/issue23078> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue36580] unittest.mock does not understand dataclasses
New submission from John Parejko : The new dataclasses.dataclass is very useful for describing the properties of a class, but it appears that Mocks of such decorated classes do not catch the members that are defined in the dataclass. I believe the root cause of this is the fact that unittest.mock.Mock generates the attributes of its spec object via `dir`, and the non-defaulted dataclass attributes do not appear in dir. Given the utility in building classes with dataclass, it would be very useful if Mocks could see the class attributes of the dataclass. Example code: import dataclasses import unittest.mock @dataclasses.dataclass class Foo: name: str baz: float bar: int = 12 FooMock = unittest.mock.Mock(Foo) fooMock = FooMock() # should fail: Foo.__init__ takes two arguments # I would expect these to be True, but they are False 'name' in dir(fooMock) 'baz' in dir(fooMock) 'bar' in dir(fooMock) -- components: Library (Lib), Tests messages: 339808 nosy: John Parejko2 priority: normal severity: normal status: open title: unittest.mock does not understand dataclasses type: behavior versions: Python 3.7 ___ Python tracker <https://bugs.python.org/issue36580> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29146] Confusing "invalid token" exception when integers have leading zero
New submission from John Parejko: As described in PEP-3127, the "leading-zeros" formatting for octal was removed from python 3. This is a good thing(tm), but the recommendation of that PEP to improve the error message of the raised exception[1] was apparently never implemented. I just ran into this while with some recently-ported python2 code, and it took a while to figure out the problem. Although this is going to be less of a problem with time as people convert to pure python3, it will be very helpful during the transition period. >>> 0o007 7 >>> 007 File "", line 1 007 ^ SyntaxError: invalid token 1: https://www.python.org/dev/peps/pep-3127/#id17 -- assignee: docs@python components: 2to3 (2.x to 3.x conversion tool), Documentation, Interpreter Core messages: 284591 nosy: John Parejko, docs@python priority: normal severity: normal status: open title: Confusing "invalid token" exception when integers have leading zero type: behavior versions: Python 3.5 ___ Python tracker <http://bugs.python.org/issue29146> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29146] Confusing "invalid token" exception when integers have leading zero
John Parejko added the comment: Ah, I finally found a related issue, and it looks like it has patches! https://bugs.python.org/issue20608 If someone could check that over and merge it, that would be wonderful! -- ___ Python tracker <http://bugs.python.org/issue29146> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20608] 'SyntaxError: invalid token' is unfriendly
Changes by John Parejko : -- nosy: +John Parejko ___ Python tracker <http://bugs.python.org/issue20608> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20608] 'SyntaxError: invalid token' is unfriendly
John Parejko added the comment: I had filed issue 29146 but eventually found this, which has patches to fix the exception messages. Could someone please look at this and get it incorporated into python? -- ___ Python tracker <http://bugs.python.org/issue20608> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com