Skip to content

Commit

Permalink
Merge pull request amyreese#24 from graingert/document-how-to-run
Browse files Browse the repository at this point in the history
document how to run
  • Loading branch information
amyreese authored Sep 4, 2020
2 parents bf027c1 + 5a99399 commit 53b3f38
Show file tree
Hide file tree
Showing 13 changed files with 104 additions and 210 deletions.
12 changes: 3 additions & 9 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
"m2r",
"sphinx.ext.autodoc",
"sphinx.ext.intersphinx",
]
extensions = ["m2r", "sphinx.ext.autodoc", "sphinx.ext.intersphinx"]

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
Expand Down Expand Up @@ -69,9 +65,7 @@
"github_repo": "fissix",
"show_powered_by": False,
"sidebar_collapse": False,
"extra_nav_links": {
"Report Issues": "https://github.com/jreese/fissix/issues",
},
"extra_nav_links": {"Report Issues": "https://github.com/jreese/fissix/issues"},
}

html_sidebars = {
Expand All @@ -81,7 +75,7 @@
"navigation.html",
"relations.html",
"searchbox.html",
],
]
}

# Add any paths that contain custom static files (such as style sheets) here,
Expand Down
4 changes: 2 additions & 2 deletions docs/fixers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
Fixers
------

Each step of transforming code is encapsulated in a fixer. The command ``2to3
-l`` lists them. As :ref:`documented above <2to3-using>`, each can be turned on
Each step of transforming code is encapsulated in a fixer. The command
``python -m fissix -l`` lists them. Each can be turned on
and off individually. They are described here in more detail.


Expand Down
40 changes: 20 additions & 20 deletions fissix/fixer_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ def ListComp(xp, fp, it, test=None):


def FromImport(package_name, name_leafs):
""" Return an import statement in the form:
from package import name_leafs"""
"""Return an import statement in the form:
from package import name_leafs"""
# XXX: May not handle dotted imports properly (eg, package_name='foo.bar')
# assert package_name == '.' or '.' not in package_name, "FromImport has "\
# "not been tested with dotted package names -- use at your own "\
Expand Down Expand Up @@ -268,11 +268,11 @@ def attr_chain(obj, attr):


def in_special_context(node):
""" Returns true if node is in an environment where all that is required
of it is being iterable (ie, it doesn't matter if it returns a list
or an iterator).
See test_map_nochange in test_fixers.py for some examples and tests.
"""
"""Returns true if node is in an environment where all that is required
of it is being iterable (ie, it doesn't matter if it returns a list
or an iterator).
See test_map_nochange in test_fixers.py for some examples and tests.
"""
global p0, p1, p2, pats_built
if not pats_built:
p0 = patcomp.compile_pattern(p0)
Expand Down Expand Up @@ -350,10 +350,10 @@ def find_root(node):


def does_tree_import(package, name, node):
""" Returns true if name is imported from package at the
top level of the tree which node belongs to.
To cover the case of an import like 'import foo', use
None for the package and 'foo' for the name. """
"""Returns true if name is imported from package at the
top level of the tree which node belongs to.
To cover the case of an import like 'import foo', use
None for the package and 'foo' for the name."""
binding = find_binding(name, find_root(node), package)
return bool(binding)

Expand All @@ -364,8 +364,8 @@ def is_import(node):


def touch_import(package, name, node):
""" Works like `does_tree_import` but adds an import statement
if it was not imported. """
"""Works like `does_tree_import` but adds an import statement
if it was not imported."""

def is_import_stmt(node):
return (
Expand Down Expand Up @@ -419,10 +419,10 @@ def is_import_stmt(node):


def find_binding(name, node, package=None):
""" Returns the node which binds variable name, otherwise None.
If optional argument package is supplied, only imports will
be returned.
See test cases for examples."""
"""Returns the node which binds variable name, otherwise None.
If optional argument package is supplied, only imports will
be returned.
See test cases for examples."""
for child in node.children:
ret = None
if child.type == syms.for_stmt:
Expand Down Expand Up @@ -481,9 +481,9 @@ def _find(name, node):


def _is_import_binding(node, name, package=None):
""" Will return node if node will import name, or node
will import * from package. None is returned otherwise.
See test cases for examples. """
"""Will return node if node will import name, or node
will import * from package. None is returned otherwise.
See test cases for examples."""

if node.type == syms.import_name and not package:
imp = node.children[1]
Expand Down
5 changes: 1 addition & 4 deletions fissix/fixes/fix_imports2.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
from . import fix_imports


MAPPING = {
"whichdb": "dbm",
"anydbm": "dbm",
}
MAPPING = {"whichdb": "dbm", "anydbm": "dbm"}


class FixImports2(fix_imports.FixImports):
Expand Down
22 changes: 11 additions & 11 deletions fissix/fixes/fix_metaclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@


def has_metaclass(parent):
""" we have to check the cls_node without changing it.
There are two possibilities:
1) clsdef => suite => simple_stmt => expr_stmt => Leaf('__meta')
2) clsdef => simple_stmt => expr_stmt => Leaf('__meta')
"""we have to check the cls_node without changing it.
There are two possibilities:
1) clsdef => suite => simple_stmt => expr_stmt => Leaf('__meta')
2) clsdef => simple_stmt => expr_stmt => Leaf('__meta')
"""
for node in parent.children:
if node.type == syms.suite:
Expand All @@ -42,8 +42,8 @@ def has_metaclass(parent):


def fixup_parse_tree(cls_node):
""" one-line classes don't get a suite in the parse tree so we add
one to normalize the tree
"""one-line classes don't get a suite in the parse tree so we add
one to normalize the tree
"""
for node in cls_node.children:
if node.type == syms.suite:
Expand All @@ -68,9 +68,9 @@ def fixup_parse_tree(cls_node):


def fixup_simple_stmt(parent, i, stmt_node):
""" if there is a semi-colon all the parts count as part of the same
simple_stmt. We just want the __metaclass__ part so we move
everything after the semi-colon into its own simple_stmt node
"""if there is a semi-colon all the parts count as part of the same
simple_stmt. We just want the __metaclass__ part so we move
everything after the semi-colon into its own simple_stmt node
"""
for semi_ind, node in enumerate(stmt_node.children):
if node.type == token.SEMI: # *sigh*
Expand Down Expand Up @@ -119,8 +119,8 @@ def find_metas(cls_node):


def fixup_indent(suite):
""" If an INDENT is followed by a thing with a prefix then nuke the prefix
Otherwise we get in trouble when removing __metaclass__ at suite start
"""If an INDENT is followed by a thing with a prefix then nuke the prefix
Otherwise we get in trouble when removing __metaclass__ at suite start
"""
kids = suite.children[::-1]
# find the first indent
Expand Down
4 changes: 1 addition & 3 deletions fissix/fixes/fix_renames.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
from .. import fixer_base
from ..fixer_util import Name, attr_chain

MAPPING = {
"sys": {"maxint": "maxsize"},
}
MAPPING = {"sys": {"maxint": "maxsize"}}
LOOKUP = {}


Expand Down
8 changes: 4 additions & 4 deletions fissix/fixes/fix_urllib.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ def build_pattern(self):

def transform_import(self, node, results):
"""Transform for the basic import case. Replaces the old
import name with a comma separated list of its
replacements.
import name with a comma separated list of its
replacements.
"""
import_mod = results.get("module")
pref = import_mod.prefix
Expand All @@ -147,8 +147,8 @@ def transform_import(self, node, results):

def transform_member(self, node, results):
"""Transform for imports of specific module elements. Replaces
the module to be imported from with the appropriate new
module.
the module to be imported from with the appropriate new
module.
"""
mod_member = results.get("mod_member")
pref = mod_member.prefix
Expand Down
2 changes: 1 addition & 1 deletion fissix/pytree.py
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ def generate_matches(patterns, nodes):
(count, results) tuples where:
count: the entire sequence of patterns matches nodes[:count];
results: dict containing named submatches.
"""
"""
if not patterns:
yield 0, {}
else:
Expand Down
8 changes: 4 additions & 4 deletions fissix/refactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ class _EveryNode(Exception):


def _get_head_types(pat):
""" Accepts a pytree Pattern Node and returns a set
of the pattern types which will match first. """
"""Accepts a pytree Pattern Node and returns a set
of the pattern types which will match first."""

if isinstance(pat, (pytree.NodePattern, pytree.LeafPattern)):
# NodePatters must either have no type and no content
Expand All @@ -73,8 +73,8 @@ def _get_head_types(pat):


def _get_headnode_dict(fixer_list):
""" Accepts a list of fixers and returns a dictionary
of head node type --> fixer list. """
"""Accepts a list of fixers and returns a dictionary
of head node type --> fixer list."""
head_nodes = collections.defaultdict(list)
every = []
for fixer in fixer_list:
Expand Down
Loading

0 comments on commit 53b3f38

Please sign in to comment.