Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
master_doc = 'index'

# General information about the project.
project = u'mando'
copyright = u'2013, Michele Lacchia'
project = 'mando'
copyright = '2013, Michele Lacchia'

# 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 @@ -199,8 +199,8 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
('index', 'mando.tex', u'mando Documentation',
u'Michele Lacchia', 'manual'),
('index', 'mando.tex', 'mando Documentation',
'Michele Lacchia', 'manual'),
]

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

# If true, show URL addresses after external links.
Expand All @@ -243,8 +243,8 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'mando', u'mando Documentation',
u'Michele Lacchia', 'mando', 'One line description of project.',
('index', 'mando', 'mando Documentation',
'Michele Lacchia', 'mando', 'One line description of project.',
'Miscellaneous'),
]

Expand Down
7 changes: 1 addition & 6 deletions mando/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
__version__ = '0.7.1'

try:
from mando.core import Program
except ImportError as e: # pragma: no cover
# unfortunately the only workaround for Python2.6, argparse and setup.py
e.version = __version__
raise e
from mando.core import Program

main = Program()
command = main.command
Expand Down
7 changes: 2 additions & 5 deletions mando/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,19 @@
import argparse
import inspect
import sys
from inspect import signature

from mando.napoleon import Config, GoogleDocstring, NumpyDocstring

from mando.utils import (purify_doc, action_by_type, find_param_docs,
split_doc, ensure_dashes, purify_kwargs)
try:
from inspect import signature
except ImportError:
from funcsigs import signature


_POSITIONAL = type('_positional', (object,), {})
_DISPATCH_TO = '_dispatch_to'


class SubProgram(object):
class SubProgram:
def __init__(self, parser, signatures):
self.parser = parser
self._subparsers = self.parser.add_subparsers()
Expand Down
8 changes: 3 additions & 5 deletions mando/napoleon/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
:license: BSD, see LICENSE for details.
"""

from six import iteritems

from mando.napoleon.docstring import GoogleDocstring, NumpyDocstring


class Config(object):
class Config:
"""Sphinx napoleon extension settings in `conf.py`.

Listed below are all the settings used by napoleon and their default
Expand Down Expand Up @@ -252,7 +250,7 @@ def __unicode__(self):

def __init__(self, **settings):
# type: (Any) -> None
for name, (default, rebuild) in iteritems(self._config_values):
for name, (default, rebuild) in self._config_values.items():
setattr(self, name, default)
for name, value in iteritems(settings):
for name, value in settings.items():
setattr(self, name, value)
22 changes: 8 additions & 14 deletions mando/napoleon/docstring.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,10 @@
:license: BSD, see LICENSE for details.
"""

try:
from collections.abc import Callable
except ImportError:
from collections import Callable
from collections.abc import Callable
import inspect
import re

from six import string_types, u
from six.moves import range

from mando.napoleon.iterators import modify_iter
from mando.napoleon.pycompat import UnicodeMixin

Expand Down Expand Up @@ -124,7 +118,7 @@ def __init__(self, docstring, config=None, app=None, what='', name='',
self._name = name
self._obj = obj
self._opt = options
if isinstance(docstring, string_types):
if isinstance(docstring, str):
docstring = docstring.splitlines()
self._lines = docstring
self._line_iter = modify_iter(docstring, modifier=lambda s: s.rstrip())
Expand Down Expand Up @@ -323,13 +317,13 @@ def _escape_args_and_kwargs(self, name):
def _fix_field_desc(self, desc):
# type: (List[unicode]) -> List[unicode]
if self._is_list(desc):
desc = [u''] + desc
desc = [''] + desc
elif desc[0].endswith('::'):
desc_block = desc[1:]
indent = self._get_indent(desc[0])
block_indent = self._get_initial_indent(desc_block)
if block_indent > indent:
desc = [u''] + desc
desc = [''] + desc
else:
desc = ['', desc[0]] + self._indent(desc_block, 4)
return desc
Expand All @@ -341,9 +335,9 @@ def _format_admonition(self, admonition, lines):
return ['.. %s:: %s' % (admonition, lines[0].strip()), '']
elif lines:
lines = self._indent(self._dedent(lines), 3)
return [u'.. %s::' % admonition, u''] + lines + [u'']
return ['.. %s::' % admonition, ''] + lines + ['']
else:
return [u'.. %s::' % admonition, u'']
return ['.. %s::' % admonition, '']

def _format_block(self, prefix, lines, padding=None):
# type: (unicode, List[unicode], unicode) -> List[unicode]
Expand Down Expand Up @@ -614,7 +608,7 @@ def _parse_methods_section(self, section):
for _name, _, _desc in self._consume_fields(parse_type=False):
lines.append('.. method:: %s' % _name)
if _desc:
lines.extend([u''] + self._indent(_desc, 3))
lines.extend([''] + self._indent(_desc, 3))
lines.append('')
return lines

Expand Down Expand Up @@ -924,7 +918,7 @@ def _is_section_header(self):
# type: () -> bool
section, underline = self._line_iter.peek(2)
section = section.lower()
if section in self._sections and isinstance(underline, string_types):
if section in self._sections and isinstance(underline, str):
return bool(_numpy_section_regex.match(underline)) # type: ignore
elif self._directive_sections:
if _directive_regex.match(section):
Expand Down
2 changes: 1 addition & 1 deletion mando/napoleon/iterators.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import collections


class peek_iter(object):
class peek_iter:
"""An iterator object that supports peeking ahead.

Parameters
Expand Down
22 changes: 5 additions & 17 deletions mando/napoleon/pycompat.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
from six import PY3
class UnicodeMixin:
"""Mixin class to handle defining the proper __str__/__unicode__
methods in Python 2 or 3."""


# UnicodeMixin
if PY3:
class UnicodeMixin(object):
"""Mixin class to handle defining the proper __str__/__unicode__
methods in Python 2 or 3."""

def __str__(self):
return self.__unicode__()
else:
class UnicodeMixin(object):
"""Mixin class to handle defining the proper __str__/__unicode__
methods in Python 2 or 3."""

def __str__(self):
return self.__unicode__().encode('utf8')
def __str__(self):
return self.__unicode__()
7 changes: 1 addition & 6 deletions mando/tests/capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@

import sys
from contextlib import contextmanager

try:
from cStringIO import StringIO
except ImportError:
from io import StringIO

from io import StringIO

@contextmanager
def capture_sys_output():
Expand Down
3 changes: 0 additions & 3 deletions mando/tests/test_unicode_docstring_on_py2.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# This is important: it will make all literals unicode under 2.x
from __future__ import unicode_literals

import unittest

from mando import Program
Expand Down
7 changes: 2 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@
else:
version = mando.__version__

deps = ["six"]
deps = []
extras = {"restructuredText": ["rst2ansi"]}


sversion = tuple(setuptools.__version__.split("."))

if sversion > ("36", "2"):
deps += ['argparse ; python_version<="2.6"', 'funcsigs ; python_version<="3.2"']
deps += ['funcsigs ; python_version<="3.2"']
elif sversion > ("18", "0"):
extras[':python_version<="2.6"'] = ["argparse"]
extras[':python_version<="3.2"'] = ["funcsigs"]


Expand Down Expand Up @@ -51,8 +50,6 @@
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.1",
"Programming Language :: Python :: 3.2",
Expand Down