Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RF: Run flake8 over all files in the repo + fix outstanding formatting issues #1107

Closed
Closed
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
10 changes: 6 additions & 4 deletions .pep8speaks.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
scanner:
diff_only: True # Only show errors caused by the patch
# Only show errors caused by the patch. False means we check everything
# according to the config for flake8 in setup.cfg
diff_only: False
linter: flake8

message: # Customize the comment made by the bot
opened: # Messages when a new PR is submitted
message: # Customize the comment made by the bot
opened: # Messages when a new PR is submitted
header: "Hello @{name}, thank you for submitting the Pull Request!"
footer: "To test for issues locally, `pip install flake8` and then run `flake8 nibabel`."
updated: # Messages when new commits are added to the PR
updated: # Messages when new commits are added to the PR
header: "Hello @{name}, Thank you for updating!"
footer: "To test for issues locally, `pip install flake8` and then run `flake8 nibabel`."
no_errors: "Cheers! There are no style issues detected in this Pull Request. :beers: "
44 changes: 18 additions & 26 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ PROJECT=nibabel
# The Python executable to be used
#
PYTHON ?= python
NOSETESTS = $(PYTHON) $(shell which nosetests)
TEST_RUNNER ?= pytest

#
# Determine details on the Python/system
Expand Down Expand Up @@ -66,7 +66,6 @@ distclean: clean
-o -iname '#*#' | xargs -L10 rm -f
-rm -r dist
-rm build-stamp
-rm -r .tox
# -rm tests/data/*.hdr.* tests/data/*.img.* tests/data/something.nii \
# tests/data/noise* tests/data/None.nii

Expand All @@ -83,22 +82,23 @@ $(WWW_DIR):
# Tests
#

test: unittest testmanual
test: test-style unittest testmanual


ut-%: build
@PYTHONPATH=.:$(PYTHONPATH) $(NOSETESTS) nibabel/tests/test_$*.py


unittest: build
@PYTHONPATH=.:$(PYTHONPATH) $(NOSETESTS) nibabel --with-doctest
unittest: build test-clean
export CHECK_TYPE=test; ./tools/ci/check.sh

testmanual: build
@cd doc/source && PYTHONPATH=../..:$(PYTHONPATH) $(NOSETESTS) --with-doctest --doctest-extension=.rst . dicom
export CHECK_TYPE=doc; ./tools/ci/check.sh

coverage: unittest

coverage: build
@PYTHONPATH=.:$(PYTHONPATH) $(NOSETESTS) --with-coverage --cover-package=nibabel
.PHONY: test-style
test-style:
export CHECK_TYPE=style; ./tools/ci/check.sh

.PHONY: test-clean
test-clean:
rm -rf for_testing


#
Expand Down Expand Up @@ -252,11 +252,13 @@ sdist-venv: clean
rm -rf dist venv
unset PYTHONPATH && $(PYTHON) setup.py sdist --formats=zip
virtualenv --system-site-packages --python=$(PYTHON) venv
. venv/bin/activate && pip install --ignore-installed nose
. venv/bin/activate && pip install -r dev-requirements.txt
mkdir venv/tmp
cd venv/tmp && unzip ../../dist/*.zip
. venv/bin/activate && cd venv/tmp/nibabel* && python setup.py install
unset PYTHONPATH && . venv/bin/activate && cd venv && nosetests --with-doctest nibabel nisext
unset PYTHONPATH && . \
venv/bin/activate && \
cd venv && $(TEST_RUNNER) --doctest-modules --doctest-plus nibabel nisext

source-release: distclean
$(PYTHON) -m compileall .
Expand All @@ -269,17 +271,7 @@ venv-tests:
make distclean
- rm -rf $(VIRTUAL_ENV)/lib/python$(PYVER)/site-packages/nibabel
$(PYTHON) setup.py install
cd .. && nosetests $(VIRTUAL_ENV)/lib/python$(PYVER)/site-packages/nibabel

tox-fresh:
# tox tests with fresh-installed virtualenvs. Needs network. And
# pytox, obviously.
tox -c tox.ini

tox-stale:
# tox tests with MB's already-installed virtualenvs (numpy and nose
# installed)
tox -e python25,python26,python27,python32,np-1.2.1
cd .. && $(TEST_RUNNER) $(VIRTUAL_ENV)/lib/python$(PYVER)/site-packages/nibabel

refresh-readme:
$(PYTHON) tools/refresh_readme.py
Expand Down
2 changes: 2 additions & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Requirements for running tests
-r requirements.txt
pytest
pytest-doctestplus
flake8
4 changes: 3 additions & 1 deletion doc-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Requirements for building docs
-r requirements.txt
sphinx<3
numpydoc
jinja2<3
numpydoc<1.3
MarkupSafe<2.1
texext
matplotlib >=1.3.1
68 changes: 33 additions & 35 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,17 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys
import os
from runpy import run_path
from configparser import ConfigParser

# Check for external Sphinx extensions we depend on
try:
import numpydoc
import numpydoc # noqa: F401
except ImportError:
raise RuntimeError('Need to install "numpydoc" package for doc build')
try:
import texext
import texext # noqa: F401
except ImportError:
raise RuntimeError('Need to install "texext" package for doc build')

Expand Down Expand Up @@ -64,7 +63,6 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.autodoc',
'sphinx.ext.doctest',
#'sphinx.ext.intersphinx',
'sphinx.ext.todo',
'sphinx.ext.mathjax',
'sphinx.ext.inheritance_diagram',
Expand All @@ -76,7 +74,7 @@

# the following doesn't work with sphinx < 1.0, but will make a separate
# sphinx-autogen run obsolete in the future
#autosummary_generate = True
# autosummary_generate = True

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
Expand All @@ -85,7 +83,7 @@
source_suffix = '.rst'

# The encoding of source files.
#source_encoding = 'utf-8'
# source_encoding = 'utf-8'

# The master toctree document.
master_doc = 'index'
Expand All @@ -105,11 +103,11 @@

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None
# language = None

# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# today = ''
# Else, today_fmt is used as the format for a strftime call.
today_fmt = '%B %d, %Y, %H:%M PDT'

Expand All @@ -124,24 +122,24 @@
exclude_trees = ['_build']

# The reST default role (used for this markup: `text`) to use for all documents
#default_role = None
# default_role = None

# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
# add_function_parentheses = True

# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True
# add_module_names = True

# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
# show_authors = False

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

# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
# modindex_common_prefix = []

# -- Sphinxext configuration --------------------------------------------------

Expand All @@ -168,26 +166,26 @@
# 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
# documentation.
#html_theme_options = {}
# html_theme_options = {}

# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
# html_theme_path = []

# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
#html_title = ''
# html_title = ''

# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
# html_short_title = None

# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = None
# html_logo = None

# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None
# html_favicon = None

# 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,
Expand All @@ -196,42 +194,42 @@

# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y'
# html_last_updated_fmt = '%b %d, %Y'

# Content template for the index page.
html_index = 'index.html'

# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
# html_use_smartypants = True

# Custom sidebar templates, maps document names to template names.
html_sidebars = {'index': ['localtoc.html', 'relations.html', 'sourcelink.html',
'indexsidebar.html', 'searchbox.html', 'reggie.html']}

# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {'index': 'index.html'}
# html_additional_pages = {'index': 'index.html'}

# If false, no module index is generated.
#html_use_modindex = True
# html_use_modindex = True

# If false, no index is generated.
#html_use_index = True
# html_use_index = True

# If true, the index is split into individual pages for each letter.
#html_split_index = False
# html_split_index = False

# If true, links to the reST sources are added to the pages.
html_show_sourcelink = True

# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
#html_use_opensearch = ''
# html_use_opensearch = ''

# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = ''
# html_file_suffix = ''

# Output file base name for HTML help builder.
htmlhelp_basename = 'nibabeldoc'
Expand All @@ -241,34 +239,34 @@
# -- Options for LaTeX output -------------------------------------------------

# The paper size ('letter' or 'a4').
#latex_paper_size = 'letter'
# latex_paper_size = 'letter'

# The font size ('10pt', '11pt' or '12pt').
#latex_font_size = '10pt'
# latex_font_size = '10pt'

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author,
# documentclass [howto/manual]).
# documentclass [howto/manual]).
latex_documents = [
('index', 'nibabel.tex', u'NiBabel Documentation', u'NiBabel Authors',
'manual')]

# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None
# latex_logo = None

# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False
# latex_use_parts = False

# Additional stuff for the LaTeX preamble.
#latex_preamble = ''
# latex_preamble = ''

# Documents to append as an appendix to all manuals.
#latex_appendices = []
# latex_appendices = []

# If false, no module index is generated.
#latex_use_modindex = True
# latex_use_modindex = True


# Example configuration for intersphinx: refer to the Python standard library.
Expand Down
2 changes: 1 addition & 1 deletion doc/source/dicom/derivations/spm_dicom_orient.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def numbered_vector(nrows, symbol_prefix):
R = zeros(4, 2)
R[:3, :] = R3

# The following is specific to the SPM algorithm.
# The following is specific to the SPM algorithm.
x1 = ones(4, 1)
y1 = ones(4, 1)
y1[:3, :] = pos_pat_0
Expand Down
3 changes: 3 additions & 0 deletions doc/source/scripts/make_coord_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
x, y = 0, 1
# Make a rectangular box with these sides


def make_ortho_box(bl, x_len, y_len):
""" Make a box with sides parallel to the axes
"""
Expand All @@ -76,6 +77,7 @@ def make_ortho_box(bl, x_len, y_len):
[bl[x], bl[y] + y_len],
[bl[x] + x_len, bl[y] + y_len]))


orth_epi_box = make_ortho_box(epi_bl, epi_x_len, epi_y_len)

# Structural bounding box
Expand Down Expand Up @@ -126,6 +128,7 @@ def plot_localizer():
def save_plot():
# Plot using global variables
plot_localizer()

def vx2mm(pts):
return pts - iso_center
plot_box(vx2mm(rot_box), label='EPI bounding box')
Expand Down
1 change: 0 additions & 1 deletion doc/tools/apigen.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,6 @@ def discover_modules(self):

def write_modules_api(self, modules, outdir):
# upper-level modules
main_module = modules[0].split('.')[0]
ulms = ['.'.join(m.split('.')[:2]) if m.count('.') >= 1
else m.split('.')[0] for m in modules]

Expand Down
Loading