Skip to content

Commit

Permalink
Merge pull request #598 from rahulporuri/cln/remove-u-prefix-str
Browse files Browse the repository at this point in the history
  • Loading branch information
Carreau committed Aug 20, 2020
2 parents 0df5f58 + 74192a0 commit a6d66cb
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 75 deletions.
14 changes: 7 additions & 7 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@
master_doc = 'index'

# General information about the project.
project = u'traitlets'
copyright = u'2015, The IPython Development Team'
author = u'The IPython Development Team'
project = 'traitlets'
copyright = '2015, The IPython Development Team'
author = 'The IPython Development Team'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -252,8 +252,8 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'traitlets.tex', u'traitlets Documentation',
u'The IPython Development Team', 'manual'),
(master_doc, 'traitlets.tex', 'traitlets Documentation',
'The IPython Development Team', 'manual'),
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -282,7 +282,7 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'traitlets', u'traitlets Documentation',
(master_doc, 'traitlets', 'traitlets Documentation',
[author], 1)
]

Expand All @@ -296,7 +296,7 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'traitlets', u'traitlets Documentation',
(master_doc, 'traitlets', 'traitlets Documentation',
author, 'traitlets', 'One line description of project.',
'Miscellaneous'),
]
Expand Down
8 changes: 4 additions & 4 deletions docs/source/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ subclass
from traitlets import Int, Float, Unicode, Bool
class MyClass(Configurable):
name = Unicode(u'defaultname'
name = Unicode('defaultname'
help="the name of the object"
).tag(config=True)
ranking = Integer(0, help="the class's ranking").tag(config=True)
Expand Down Expand Up @@ -239,11 +239,11 @@ to be reflected in the configuration system. Here is a simple example::
from traitlets import Integer, Float, Unicode, Bool

class Foo(Configurable):
name = Unicode(u'fooname', config=True)
name = Unicode('fooname', config=True)
value = Float(100.0, config=True)

class Bar(Foo):
name = Unicode(u'barname', config=True)
name = Unicode('barname', config=True)
othervalue = Int(0, config=True)

Now, we can create a configuration file to configure instances of :class:`Foo`
Expand All @@ -252,7 +252,7 @@ and :class:`Bar`::
# config file
c = get_config()

c.Foo.name = u'bestname'
c.Foo.name = 'bestname'
c.Bar.othervalue = 10

This class hierarchy and configuration file accomplishes the following:
Expand Down
6 changes: 3 additions & 3 deletions examples/myapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Foo(Configurable):

i = Int(0, help="The integer i.").tag(config=True)
j = Int(1, help="The integer j.").tag(config=True)
name = Unicode(u'Brian', help="First name.").tag(config=True, shortname="B")
name = Unicode('Brian', help="First name.").tag(config=True, shortname="B")


class Bar(Configurable):
Expand All @@ -54,11 +54,11 @@ class Bar(Configurable):

class MyApp(Application):

name = Unicode(u'myapp')
name = Unicode('myapp')
running = Bool(False,
help="Is the app running?").tag(config=True)
classes = List([Bar, Foo])
config_file = Unicode(u'',
config_file = Unicode('',
help="Load this config file").tag(config=True)

aliases = Dict(dict(i='Foo.i',j='Foo.j',name='Foo.name', running='MyApp.running',
Expand Down
6 changes: 3 additions & 3 deletions traitlets/config/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ class Application(SingletonConfigurable):

# The name of the application, will usually match the name of the command
# line application
name = Unicode(u'application')
name = Unicode('application')

# The description of the application that is printed at the beginning
# of the help.
description = Unicode(u'This is an application.')
description = Unicode('This is an application.')
# default section descriptions
option_description = Unicode(option_description)
keyvalue_description = Unicode(keyvalue_description)
Expand Down Expand Up @@ -162,7 +162,7 @@ def _classes_inc_parents(self, classes=None):
yield parent

# The version string of this application.
version = Unicode(u'0.0')
version = Unicode('0.0')

# the argv used to initialize the application
argv = List()
Expand Down
8 changes: 4 additions & 4 deletions traitlets/config/configurable.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,11 @@ def _load_config(self, cfg, section_names=None, traits=None):
else:
warn = lambda msg: warnings.warn(msg, stacklevel=9)
matches = get_close_matches(name, traits)
msg = u"Config option `{option}` not recognized by `{klass}`.".format(
msg = "Config option `{option}` not recognized by `{klass}`.".format(
option=name, klass=self.__class__.__name__)

if len(matches) == 1:
msg += u" Did you mean `{matches}`?".format(matches=matches[0])
msg += " Did you mean `{matches}`?".format(matches=matches[0])
elif len(matches) >= 1:
msg +=" Did you mean one of: `{matches}`?".format(matches=', '.join(sorted(matches)))
warn(msg)
Expand Down Expand Up @@ -230,8 +230,8 @@ class defaults.
assert inst is None or isinstance(inst, cls)
final_help = []
base_classes = ', '.join(p.__name__ for p in cls.__bases__)
final_help.append(u'%s(%s) options' % (cls.__name__, base_classes))
final_help.append(len(final_help[0])*u'-')
final_help.append('%s(%s) options' % (cls.__name__, base_classes))
final_help.append(len(final_help[0])*'-')
for k, v in sorted(cls.class_traits(config=True).items()):
help = cls.class_get_trait_help(v, inst)
final_help.append(help)
Expand Down
12 changes: 6 additions & 6 deletions traitlets/config/tests/test_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class Foo(Configurable):
Details about i.
""").tag(config=True)
j = Integer(1, help="The integer j.").tag(config=True)
name = Unicode(u'Brian', help="First name.").tag(config=True)
name = Unicode('Brian', help="First name.").tag(config=True)
la = List([]).tag(config=True)
li = List(Integer()).tag(config=True)
fdict = Dict().tag(config=True, multiplicity='+')
Expand All @@ -73,12 +73,12 @@ class Bar(Configurable):

class MyApp(Application):

name = Unicode(u'myapp')
name = Unicode('myapp')
running = Bool(False, help="Is the app running?").tag(config=True)
classes = List([Bar, Foo])
config_file = Unicode(u'', help="Load this config file").tag(config=True)
config_file = Unicode('', help="Load this config file").tag(config=True)

warn_tpyo = Unicode(u"yes the name is wrong on purpose", config=True,
warn_tpyo = Unicode("yes the name is wrong on purpose", config=True,
help="Should print a warning if `MyApp.warn-typo=...` command is passed")

aliases = {}
Expand Down Expand Up @@ -140,10 +140,10 @@ def test_no_eval_cli_text(self):

def test_basic(self):
app = MyApp()
self.assertEqual(app.name, u'myapp')
self.assertEqual(app.name, 'myapp')
self.assertEqual(app.running, False)
self.assertEqual(app.classes, [MyApp, Bar, Foo])
self.assertEqual(app.config_file, u'')
self.assertEqual(app.config_file, '')

def test_mro_discovery(self):
app = MyApp()
Expand Down
8 changes: 4 additions & 4 deletions traitlets/config/tests/test_configurable.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class MyConfigurable(Configurable):
c = Unicode('no config')


mc_help = u"""MyConfigurable(Configurable) options
mc_help = """MyConfigurable(Configurable) options
------------------------------------
--MyConfigurable.a=<Integer>
The integer a.
Expand All @@ -38,7 +38,7 @@ class MyConfigurable(Configurable):
The integer b.
Default: 1.0"""

mc_help_inst=u"""MyConfigurable(Configurable) options
mc_help_inst="""MyConfigurable(Configurable) options
------------------------------------
--MyConfigurable.a=<Integer>
The integer a.
Expand Down Expand Up @@ -66,7 +66,7 @@ class Bar(Foo):
bdict = Dict().tag(config=True, multiplicity='+')
bdict_values = Dict({1:'a','0':'b',5:'c'}).tag(config=True, multiplicity='+')

foo_help=u"""Foo(Configurable) options
foo_help="""Foo(Configurable) options
-------------------------
--Foo.a=<Int>
The integer a.
Expand All @@ -78,7 +78,7 @@ class Bar(Foo):
--Foo.flist=<list-item-1>...
Default: []"""

bar_help=u"""Bar(Foo) options
bar_help="""Bar(Foo) options
----------------
--Bar.a=<Int>
The integer a.
Expand Down
20 changes: 10 additions & 10 deletions traitlets/config/tests/test_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def _check_conf(self, config):
self.assertEqual(config.D.C.value, 'hi there')

def test_python(self):
fd, fname = mkstemp('.py', prefix=u'μnïcø∂e')
fd, fname = mkstemp('.py', prefix='μnïcø∂e')
f = os.fdopen(fd, 'w')
f.write(pyfile)
f.close()
Expand All @@ -93,7 +93,7 @@ def test_python(self):
self._check_conf(config)

def test_json(self):
fd, fname = mkstemp('.json', prefix=u'μnïcø∂e')
fd, fname = mkstemp('.json', prefix='μnïcø∂e')
f = os.fdopen(fd, 'w')
f.write(json1file)
f.close()
Expand All @@ -104,7 +104,7 @@ def test_json(self):

def test_context_manager(self):

fd, fname = mkstemp('.json', prefix=u'μnïcø∂e')
fd, fname = mkstemp('.json', prefix='μnïcø∂e')
f = os.fdopen(fd, 'w')
f.write('{}')
f.close()
Expand All @@ -123,7 +123,7 @@ def test_context_manager(self):
self.assertEqual(cl.config.MyAttr.value, value)

def test_json_context_bad_write(self):
fd, fname = mkstemp('.json', prefix=u'μnïcø∂e')
fd, fname = mkstemp('.json', prefix='μnïcø∂e')
f = os.fdopen(fd, 'w')
f.write('{}')
f.close()
Expand Down Expand Up @@ -169,7 +169,7 @@ def test_collision(self):
})

def test_v2raise(self):
fd, fname = mkstemp('.json', prefix=u'μnïcø∂e')
fd, fname = mkstemp('.json', prefix='μnïcø∂e')
f = os.fdopen(fd, 'w')
f.write(json2file)
f.close()
Expand Down Expand Up @@ -314,10 +314,10 @@ def test_extra_args(self):

def test_unicode_args(self):
cl = self.klass(log=log)
argv = [u'--a=épsîlön']
argv = ['--a=épsîlön']
config = cl.load_config(argv)
print(config, cl.extra_args)
self.assertEqual(config.a, u'épsîlön')
self.assertEqual(config.a, 'épsîlön')

def test_list_append(self):
cl = self.klass(log=log)
Expand Down Expand Up @@ -374,12 +374,12 @@ def test_int_literals(self):

def test_unicode_alias(self):
cl = self.klass(log=log)
argv = [u'--a=épsîlön']
argv = ['--a=épsîlön']
config = cl.load_config(argv, aliases=dict(a='A.a'))
print(dict(config))
print(cl.extra_args)
print(cl.aliases)
self.assertEqual(config.A.a, u'épsîlön')
self.assertEqual(config.A.a, 'épsîlön')

def test_expanduser2(self):
cl = self.klass(log=log)
Expand All @@ -398,7 +398,7 @@ def test_eval(self):
cl = self.klass(log=log)
argv = ['-c', 'a=5']
config = cl.load_config(argv, aliases=dict(c='A.c'))
self.assertEqual(config.A.c, u"a=5")
self.assertEqual(config.A.c, "a=5")

def test_seq_traits(self):
cl = self.klass(log=log, classes=(CBase, CSub))
Expand Down

0 comments on commit a6d66cb

Please sign in to comment.