Skip to content

Commit

Permalink
Format code using black
Browse files Browse the repository at this point in the history
So we can automatically fix many formatting issues.

https://black.readthedocs.io/

Drop pypy3 testing due to python/typed_ast#111
  • Loading branch information
jogo committed Jul 16, 2020
1 parent 02b10a3 commit a4c5554
Show file tree
Hide file tree
Showing 19 changed files with 492 additions and 440 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, pypy3]
python-version: [3.6, 3.7, 3.8]

steps:
- uses: actions/checkout@v2
Expand All @@ -26,8 +26,9 @@ jobs:
- name: Lint
if: matrix.python-version == '3.8'
run: |
pip install flake8
pip install flake8 black
flake8 git_stacktrace
black --check .
- name: Run Tests via Tox
# Run tox using the version of Python in `PATH`
run: tox -e py
64 changes: 30 additions & 34 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import git_stacktrace

sys.path.insert(0, os.path.abspath('.'))
sys.path.insert(0, os.path.abspath("."))


# -- General configuration ------------------------------------------------
Expand All @@ -33,27 +33,24 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.viewcode',
'sphinx.ext.intersphinx']
extensions = ["sphinx.ext.autodoc", "sphinx.ext.viewcode", "sphinx.ext.intersphinx"]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
source_suffix = ".rst"

# The master toctree document.
master_doc = 'index'
master_doc = "index"

# General information about the project.
project = u'git-stacktrace'
copyright = u'2017 Pinterest, Inc'
author = u'Joe Gordon'
project = u"git-stacktrace"
copyright = u"2017 Pinterest, Inc"
author = u"Joe Gordon"


# The version info for the project you're documenting, acts as replacement for
Expand All @@ -78,7 +75,7 @@
exclude_patterns = []

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = "sphinx"

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False
Expand All @@ -89,7 +86,7 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'
html_theme = "sphinx_rtd_theme"

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
Expand All @@ -100,28 +97,28 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]

# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
# This is required for the alabaster theme
# refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars
html_sidebars = {
'**': [
'about.html',
'navigation.html',
'relations.html', # needs 'show_related': True theme option to display
'searchbox.html',
'donate.html',
"**": [
"about.html",
"navigation.html",
"relations.html", # needs 'show_related': True theme option to display
"searchbox.html",
"donate.html",
]
}


# -- Options for HTMLHelp output ------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'git-stacktracedoc'
htmlhelp_basename = "git-stacktracedoc"


# -- Options for LaTeX output ---------------------------------------------
Expand All @@ -130,15 +127,12 @@
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',

# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
Expand All @@ -148,19 +142,15 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'git-stacktrace.tex', u'git-stacktrace Documentation',
u'Joe Gordon', 'manual'),
(master_doc, "git-stacktrace.tex", u"git-stacktrace Documentation", u"Joe Gordon", "manual"),
]


# -- Options for manual page output ---------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'git-stacktrace', u'git-stacktrace Documentation',
[author], 1)
]
man_pages = [(master_doc, "git-stacktrace", u"git-stacktrace Documentation", [author], 1)]


# -- Options for Texinfo output -------------------------------------------
Expand All @@ -169,11 +159,17 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'git-stacktrace', u'git-stacktrace Documentation',
author, 'git-stacktrace', 'One line description of project.',
'Miscellaneous'),
(
master_doc,
"git-stacktrace",
u"git-stacktrace Documentation",
author,
"git-stacktrace",
"One line description of project.",
"Miscellaneous",
),
]


# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'https://docs.python.org/': None}
intersphinx_mapping = {"https://docs.python.org/": None}
2 changes: 1 addition & 1 deletion git_stacktrace/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import pkg_resources

__version__ = pkg_resources.get_provider(pkg_resources.Requirement.parse('git-stacktrace')).version
__version__ = pkg_resources.get_provider(pkg_resources.Requirement.parse("git-stacktrace")).version
2 changes: 1 addition & 1 deletion git_stacktrace/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

def _longest_filename(matches):
"""find longest match by number of '/'."""
return max(matches, key=lambda filename: len(filename.split('/')))
return max(matches, key=lambda filename: len(filename.split("/")))


def _lookup_files(commit_files, git_files, traceback, results):
Expand Down
45 changes: 29 additions & 16 deletions git_stacktrace/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,42 @@ def main():
description = "Lookup commits related to a given stacktrace."
parser = argparse.ArgumentParser(usage=usage, description=description)
range_group = parser.add_mutually_exclusive_group()
range_group.add_argument('--since', metavar="<date1>", help='show commits '
'more recent than a specific date (from git-log)')
range_group.add_argument('range', nargs='?', help='git commit range to use')
range_group.add_argument('--server', action="store_true", help='start a '
'webserver to visually interact with git-stacktrace')
parser.add_argument('--port', default=os.environ.get('GIT_STACKTRACE_PORT', 8080),
type=int, help='Server port')
parser.add_argument('-f', '--fast', action="store_true", help='Speed things up by not running '
'pickaxe if the file for a line of code cannot be found')
parser.add_argument('-b', '--branch', nargs='?', help='Git branch. If using --since, use this to '
'specify which branch to run since on. Runs on current branch by default')
parser.add_argument('--version', action="version",
version='%s version %s' % (os.path.split(sys.argv[0])[-1], git_stacktrace.__version__))
parser.add_argument('-d', '--debug', action='store_true', help='Enable debug logging')
range_group.add_argument(
"--since", metavar="<date1>", help="show commits " "more recent than a specific date (from git-log)"
)
range_group.add_argument("range", nargs="?", help="git commit range to use")
range_group.add_argument(
"--server", action="store_true", help="start a " "webserver to visually interact with git-stacktrace"
)
parser.add_argument("--port", default=os.environ.get("GIT_STACKTRACE_PORT", 8080), type=int, help="Server port")
parser.add_argument(
"-f",
"--fast",
action="store_true",
help="Speed things up by not running " "pickaxe if the file for a line of code cannot be found",
)
parser.add_argument(
"-b",
"--branch",
nargs="?",
help="Git branch. If using --since, use this to "
"specify which branch to run since on. Runs on current branch by default",
)
parser.add_argument(
"--version",
action="version",
version="%s version %s" % (os.path.split(sys.argv[0])[-1], git_stacktrace.__version__),
)
parser.add_argument("-d", "--debug", action="store_true", help="Enable debug logging")
args = parser.parse_args()

logging.basicConfig(format='%(name)s:%(funcName)s:%(lineno)s: %(message)s')
logging.basicConfig(format="%(name)s:%(funcName)s:%(lineno)s: %(message)s")
if args.debug:
logging.getLogger().setLevel(logging.DEBUG)

if args.server:
print("Starting httpd on port %s..." % args.port)
httpd = make_server('', args.port, server.application)
httpd = make_server("", args.port, server.application)
try:
httpd.serve_forever()
except KeyboardInterrupt:
Expand Down
Loading

0 comments on commit a4c5554

Please sign in to comment.