Hello community, here is the log from the commit of package python-traits for openSUSE:Factory checked in at 2019-07-22 12:21:50 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-traits (Old) and /work/SRC/openSUSE:Factory/.python-traits.new.4126 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-traits" Mon Jul 22 12:21:50 2019 rev:5 rq:717484 version:5.1.2 Changes: -------- --- /work/SRC/openSUSE:Factory/python-traits/python-traits.changes 2019-04-30 12:59:13.450163870 +0200 +++ /work/SRC/openSUSE:Factory/.python-traits.new.4126/python-traits.changes 2019-07-22 12:21:51.471641265 +0200 @@ -1,0 +2,6 @@ +Mon Jul 22 08:56:26 UTC 2019 - Tomáš Chvátal <[email protected]> + +- Update to 5.1.2: + * Traits documenter no longer generates bad reST for traits whose definition spans multiple source lines. (#494) + +------------------------------------------------------------------- Old: ---- traits-5.1.1.tar.gz New: ---- traits-5.1.2.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-traits.spec ++++++ --- /var/tmp/diff_new_pack.zlctOj/_old 2019-07-22 12:21:52.127641093 +0200 +++ /var/tmp/diff_new_pack.zlctOj/_new 2019-07-22 12:21:52.127641093 +0200 @@ -19,7 +19,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} %define oldpython python Name: python-traits -Version: 5.1.1 +Version: 5.1.2 Release: 0 Summary: Explicitly typed attributes for Python # Images have different licenses. For image license breakdown check ++++++ traits-5.1.1.tar.gz -> traits-5.1.2.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/traits-5.1.1/CHANGES.rst new/traits-5.1.2/CHANGES.rst --- old/traits-5.1.1/CHANGES.rst 2019-04-18 11:26:35.000000000 +0200 +++ new/traits-5.1.2/CHANGES.rst 2019-07-08 10:05:13.000000000 +0200 @@ -1,6 +1,17 @@ Traits CHANGELOG ================ +Release 5.1.2 +------------- + +Released: 2019-07-08 + +Fixes + +* Traits documenter no longer generates bad reST for traits whose definition + spans multiple source lines. (#494) + + Release 5.1.1 ------------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/traits-5.1.1/PKG-INFO new/traits-5.1.2/PKG-INFO --- old/traits-5.1.1/PKG-INFO 2019-04-18 11:30:48.000000000 +0200 +++ new/traits-5.1.2/PKG-INFO 2019-07-08 10:09:16.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.2 Name: traits -Version: 5.1.1 +Version: 5.1.2 Summary: explicitly typed attributes for Python Home-page: http://docs.enthought.com/traits Author: David C. Morrill, et. al. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/traits-5.1.1/setup.py new/traits-5.1.2/setup.py --- old/traits-5.1.1/setup.py 2019-04-18 11:26:35.000000000 +0200 +++ new/traits-5.1.2/setup.py 2019-07-08 10:05:13.000000000 +0200 @@ -9,7 +9,7 @@ MAJOR = 5 MINOR = 1 -MICRO = 1 +MICRO = 2 IS_RELEASED = True diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/traits-5.1.1/traits/_version.py new/traits-5.1.2/traits/_version.py --- old/traits-5.1.1/traits/_version.py 2019-04-18 11:30:47.000000000 +0200 +++ new/traits-5.1.2/traits/_version.py 2019-07-08 10:09:12.000000000 +0200 @@ -1,7 +1,7 @@ # THIS FILE IS GENERATED FROM TRAITS SETUP.PY -version = '5.1.1' -full_version = '5.1.1' -git_revision = 'e2fe1b95dc0660321350aab09428a811922acc78' +version = '5.1.2' +full_version = '5.1.2' +git_revision = 'e62cb0a15195e14f5aa916f941d9a93a488a04fd' is_released = True if not is_released: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/traits-5.1.1/traits/util/tests/test_trait_documenter.py new/traits-5.1.2/traits/util/tests/test_trait_documenter.py --- old/traits-5.1.1/traits/util/tests/test_trait_documenter.py 2019-04-18 10:44:37.000000000 +0200 +++ new/traits-5.1.2/traits/util/tests/test_trait_documenter.py 2019-07-08 09:37:51.000000000 +0200 @@ -1,30 +1,66 @@ # -*- coding: utf-8 -*- """ Tests for the trait documenter. """ - +import contextlib +import io +import os +import shutil +import tempfile import textwrap import tokenize import unittest +try: + # Python 3: mock in the standard library. + import unittest.mock as mock +except ImportError: + # Python 2: need to use 3rd-party mock. + import mock import six -if six.PY2: - import mock + +try: + import sphinx # noqa: F401 +except ImportError: + sphinx_available = False else: - import unittest.mock as mock + sphinx_available = True +from traits.api import HasTraits, Int -def _sphinx_present(): - try: - import sphinx # noqa - except ImportError: - return False +if sphinx_available: + from sphinx.ext.autodoc import Options + from sphinx.ext.autodoc.directive import DocumenterBridge + from sphinx.testing.path import path + from sphinx.testing.util import SphinxTestApp + from sphinx.util.docutils import LoggingReporter + + from traits.util.trait_documenter import ( + _get_definition_tokens, + TraitDocumenter, + ) + +skip_unless_sphinx_present = unittest.skipUnless( + sphinx_available, + "Sphinx is not available. Cannot test documenter.", +) - return True +class MyTestClass(HasTraits): + """ + Class-level docstring. + """ + #: I'm a troublesome trait with a long definition. + bar = Int(42, desc=""" First line + + The answer to + Life, + the Universe, [email protected]( - not _sphinx_present(), "Sphinx not available. Cannot test documenter" -) + and Everything. + """) + + +@skip_unless_sphinx_present class TestTraitDocumenter(unittest.TestCase): """ Tests for the trait documenter. """ @@ -38,9 +74,6 @@ self.tokens = tokens def test_get_definition_tokens(self): - - from traits.util.trait_documenter import _get_definition_tokens - src = textwrap.dedent( """\ depth_interval = Property(Tuple(Float, Float), @@ -59,8 +92,6 @@ def test_add_line(self): - from traits.util.trait_documenter import TraitDocumenter - src = textwrap.dedent( """\ class Fake(HasTraits): @@ -87,3 +118,61 @@ self.assertEqual( len(documenter.directive.result.append.mock_calls), 1) + + def test_abbreviated_annotations(self): + # Regression test for enthought/traits#493. + with self.create_test_directive() as directive: + documenter = TraitDocumenter( + directive, __name__ + ".MyTestClass.bar") + documenter.generate(all_members=True) + result = directive.result + + # Find annotations line. + for item in result: + if item.lstrip().startswith(":annotation:"): + break + else: + self.fail("Didn't find the expected trait :annotation:") + + # Annotation should be a single line. + self.assertIn("First line", item) + self.assertNotIn("\n", item) + + @contextlib.contextmanager + def create_test_directive(self): + """ + Helper function to create a a "directive" suitable + for instantiating the TraitDocumenter with, along with resources + to support that directive, and clean up the resources afterwards. + + Returns + ------- + contextmanager + A context manager that returns a DocumenterBridge instance. + """ + with self.tmpdir() as tmpdir: + # The configuration file must exist, but it's okay if it's empty. + conf_file = os.path.join(tmpdir, "conf.py") + with io.open(conf_file, "w", encoding="utf-8"): + pass + + app = SphinxTestApp(srcdir=path(tmpdir)) + app.builder.env.app = app + app.builder.env.temp_data["docname"] = "dummy" + yield DocumenterBridge(app.env, LoggingReporter(''), Options(), 1) + + @contextlib.contextmanager + def tmpdir(self): + """ + Helper function to create a temporary directory. + + Returns + ------- + contextmanager + Context manager that returns the path to a temporary directory. + """ + tmpdir = tempfile.mkdtemp() + try: + yield tmpdir + finally: + shutil.rmtree(tmpdir) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/traits-5.1.1/traits/util/trait_documenter.py new/traits-5.1.2/traits/util/trait_documenter.py --- old/traits-5.1.1/traits/util/trait_documenter.py 2019-04-18 10:44:37.000000000 +0200 +++ new/traits-5.1.2/traits/util/trait_documenter.py 2019-07-08 09:37:50.000000000 +0200 @@ -112,6 +112,12 @@ """ ClassLevelDocumenter.add_directive_header(self, sig) definition = self._get_trait_definition() + + # Workaround for enthought/traits#493: if the definition is multiline, + # throw away all lines after the first. + if "\n" in definition: + definition = definition.partition("\n")[0] + u" …" + self.add_line(u" :annotation: = {0}".format(definition), "<autodoc>") # Private Interface ##################################################### diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/traits-5.1.1/traits.egg-info/PKG-INFO new/traits-5.1.2/traits.egg-info/PKG-INFO --- old/traits-5.1.1/traits.egg-info/PKG-INFO 2019-04-18 11:30:47.000000000 +0200 +++ new/traits-5.1.2/traits.egg-info/PKG-INFO 2019-07-08 10:09:14.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.2 Name: traits -Version: 5.1.1 +Version: 5.1.2 Summary: explicitly typed attributes for Python Home-page: http://docs.enthought.com/traits Author: David C. Morrill, et. al.
