Repository: ipython/traitlets
Pull request #528 (2019-08-01 20:15:46)

Fix formatting.
Make this a bulleted list in sphinx, as intended.


Patch:
diff --git a/.travis.yml b/.travis.yml
index 8cb2aee..d7c928f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -11,7 +11,6 @@ install:
   - pip install .
   - pip install --pre --upgrade traitlets[test] pytest pytest-cov codecov
   - test -z ${TEST_DEPS} || pip install --upgrade ${TEST_DEPS}
-  - pip freeze
 
 script:
   - ${TEST:-py.test --cov traitlets -v traitlets}
@@ -27,7 +26,7 @@ matrix:
         - TEST=iptest
     - python: 3.6
       env:
-        - TEST_DEPS=git+https://github.com/jupyter/nbconvert.git#egg=nbconvert[test]
+        - TEST_DEPS=nbconvert[test]
         - TEST="py.test --pyargs nbconvert"
     - python: 3.6
       env:
@@ -36,7 +35,7 @@ matrix:
     - python: 3.6
       env:
         - TEST_DEPS=ipywidgets[test]
-        - TEST="pytest --pyargs ipywidgets"
+        - TEST="nosetests ipywidgets"
     - python: 3.6
       env:
         - TEST_DEPS=traittypes[test]
diff --git a/docs/source/trait_types.rst b/docs/source/trait_types.rst
index 1b29344..3c67003 100644
--- a/docs/source/trait_types.rst
+++ b/docs/source/trait_types.rst
@@ -110,7 +110,5 @@ Miscellaneous
 .. autoclass:: Union
    :members: __init__
 
-.. autoclass:: Callable
-
 .. autoclass:: Any
 
diff --git a/traitlets/config/application.py b/traitlets/config/application.py
index e7c28e9..b439822 100644
--- a/traitlets/config/application.py
+++ b/traitlets/config/application.py
@@ -754,11 +754,6 @@ class Application(SingletonConfigurable):
                     loaded.append(config)
                     filenames.append(loader.full_filename)
 
-    @property
-    def loaded_config_files(self):
-        """Currently loaded configuration files"""
-        return self._loaded_config_files[:]
-
     @catch_config_error
     def load_config_file(self, filename, path=None):
         """Load config files by filename and path."""
@@ -768,8 +763,7 @@ class Application(SingletonConfigurable):
             raise_config_file_errors=self.raise_config_file_errors,
         ):
             new_config.merge(config)
-            if filename not in self._loaded_config_files:  # only add to list of loaded files if not previously loaded
-                self._loaded_config_files.append(filename)
+            self._loaded_config_files.append(filename)
         # add self.cli_config to preserve CLI config priority
         new_config.merge(self.cli_config)
         self.update_config(new_config)
diff --git a/traitlets/config/loader.py b/traitlets/config/loader.py
index 12d4592..122a6d5 100644
--- a/traitlets/config/loader.py
+++ b/traitlets/config/loader.py
@@ -918,7 +918,7 @@ class KVArgParseConfigLoader(ArgParseConfigLoader):
                 if key in self.aliases:
                     alias_flags[self.aliases[key]] = value
                     continue
-                keys = ('-'+key, '--'+key) if len(key) == 1 else ('--'+key, )
+                keys = ('-'+key, '--'+key) if len(key) is 1 else ('--'+key, )
                 paa(*keys, action=_FlagAction, flag=value)
 
         for keys, traitname in aliases.items():
@@ -943,7 +943,7 @@ class KVArgParseConfigLoader(ArgParseConfigLoader):
                     argparse_kwds['action'] = _FlagAction
                     argparse_kwds['flag'] = alias_flags[traitname]
                     argparse_kwds['alias'] = traitname
-                keys = ('-'+key, '--'+key) if len(key) == 1 else ('--'+key, )
+                keys = ('-'+key, '--'+key) if len(key) is 1 else ('--'+key, )
                 paa(*keys, **argparse_kwds)
 
     def _convert_to_config(self):
diff --git a/traitlets/traitlets.py b/traitlets/traitlets.py
index efb45d5..ce44c8e 100644
--- a/traitlets/traitlets.py
+++ b/traitlets/traitlets.py
@@ -521,13 +521,9 @@ class TraitType(BaseDescriptor):
             # Check for a dynamic initializer.
             default = obj.trait_defaults(self.name)
             if default is Undefined:
-                warn(
-                    "Explicit using of Undefined as the default value "
-                    "is deprecated in traitlets 4.4, and may cause "
-                    "exceptions in the future",
-                    DeprecationWarning,
-                    stacklevel=2
-                )
+                raise TraitError("No default value found for "
+                    "the '%s' trait named '%s' of %r" % (
+                    type(self).__name__, self.name, obj))
             with obj.cross_validation_lock:
                 value = self._validate(obj, default)
             obj._trait_values[self.name] = value
@@ -881,6 +877,7 @@ def validate(*names):
 
     The handler passed to the decorator must have one ``proposal`` dict argument.
     The proposal dictionary must hold the following keys:
+
     * ``owner`` : the HasTraits instance
     * ``value`` : the proposed value for the modified trait attribute
     * ``trait`` : the TraitType instance associated with the attribute


Test patch:
diff --git a/traitlets/config/tests/test_application.py b/traitlets/config/tests/test_application.py
index 30b8917..bf66eb7 100644
--- a/traitlets/config/tests/test_application.py
+++ b/traitlets/config/tests/test_application.py
@@ -547,48 +547,6 @@ class TestApplication(TestCase):
         self.assertIs(app.subapp.parent, app)
         self.assertIs(app.subapp.subapp.parent, app.subapp)     # Set by factory.
 
-    def test_loaded_config_files(self):
-        app = MyApp()
-        app.log = logging.getLogger()
-        name = 'config.py'
-        with TemporaryDirectory('_1') as td1:
-            config_file = pjoin(td1, name)
-            with open(config_file, 'w') as f:
-                f.writelines([
-                    "c.MyApp.running = True\n"
-                ])
-
-            app.load_config_file(name, path=[td1])
-            self.assertEqual(len(app.loaded_config_files), 1)
-            self.assertEquals(app.loaded_config_files[0], config_file)
-
-            app.start()
-            self.assertEqual(app.running, True)
-
-            # emulate an app that allows dynamic updates and update config file
-            with open(config_file, 'w') as f:
-                f.writelines([
-                    "c.MyApp.running = False\n"
-                ])
-
-            # reload and verify update, and that loaded_configs was not increased
-            app.load_config_file(name, path=[td1])
-            self.assertEqual(len(app.loaded_config_files), 1)
-            self.assertEqual(app.running, False)
-
-            # Attempt to update, ensure error...
-            with self.assertRaises(AttributeError):
-                app.loaded_config_files = "/foo"
-
-            # ensure it can't be udpated via append
-            app.loaded_config_files.append("/bar")
-            self.assertEqual(len(app.loaded_config_files), 1)
-
-            # repeat to ensure no unexpected changes occurred
-            app.load_config_file(name, path=[td1])
-            self.assertEqual(len(app.loaded_config_files), 1)
-            self.assertEqual(app.running, False)
-
 
 class Root(Application):
     subcommands = {
diff --git a/traitlets/tests/test_traitlets.py b/traitlets/tests/test_traitlets.py
index e2efe30..acb8a63 100644
--- a/traitlets/tests/test_traitlets.py
+++ b/traitlets/tests/test_traitlets.py
@@ -56,7 +56,8 @@ class TestTraitType(TestCase):
         class A(HasTraits):
             a = TraitType
         a = A()
-        assert a.a is Undefined
+        with self.assertRaises(TraitError):
+            a.a
 
     def test_set(self):
         class A(HasTraitsStub):