Skip to content

MNT: Add and apply pre-commit configuration #1169

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

Merged
merged 8 commits into from
Jan 2, 2023
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
4 changes: 3 additions & 1 deletion .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Sun Jan 1 12:38:02 2023 -0500 - [email protected] - STY: Run pre-commit config on all files
d14c1cf282a9c3b19189f490f10c35f5739e24d1
# Thu Dec 29 22:53:17 2022 -0500 - [email protected] - STY: Reduce array().astype() and similar constructs
bf298113da99079c9c7b5e1690e41879828cd472
# Thu Dec 29 22:32:46 2022 -0500 - [email protected] - STY: pyupgrade --py37-plus
Expand All @@ -9,4 +11,4 @@ bf298113da99079c9c7b5e1690e41879828cd472
# Thu Dec 29 21:32:00 2022 -0500 - [email protected] - STY: isort
0ab2856cac4d4baae7ab3e2f6d58421db55d807f
# Thu Dec 29 21:30:29 2022 -0500 - [email protected] - STY: blue
1a8dd302ff85b1136c81d492509b80e7748339f0
1a8dd302ff85b1136c81d492509b80e7748339f0
22 changes: 22 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
exclude: '.*/data/.*'
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-json
- id: check-toml
- id: check-added-large-files
- id: check-case-conflict
- id: check-merge-conflict
- id: check-vcs-permalinks
- repo: https://github.com/grantjenks/blue
rev: v0.9.1
hooks:
- id: blue
- repo: https://github.com/pycqa/isort
rev: 5.11.2
hooks:
- id: isort
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ RELEASE_VERSION ?= $(SETUPPY_VERSION)

all: build

build:
build:
$(PYTHON) setup.py config --noisy
$(PYTHON) setup.py build

Expand Down Expand Up @@ -81,6 +81,7 @@ $(WWW_DIR):
.git-blame-ignore-revs:
git log --grep "\[git-blame-ignore-rev\]" --pretty=format:"# %ad - %ae - %s%n%H" \
> .git-blame-ignore-revs
echo >> .git-blame-ignore-revs

#
# Tests
Expand Down
2 changes: 1 addition & 1 deletion Makefile.win
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Makefile NiBabel under Windows using a standard Python distribution

installer:
installer:
# now the installer
python setup.py bdist_wininst

Expand Down
1 change: 0 additions & 1 deletion bin/nib-ls
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@ Output a summary table for neuroimaging files (resolution, dimensionality, etc.)

from nibabel.cmdline.ls import main


if __name__ == '__main__':
main()
2 changes: 1 addition & 1 deletion bin/nib-nifti-dx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# copyright and license terms.
#
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
""" Print nifti diagnostics for header files """
"""Print nifti diagnostics for header files"""

from nibabel.cmdline.nifti_dx import main

Expand Down
1 change: 0 additions & 1 deletion bin/parrec2nii
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@

from nibabel.cmdline.parrec2nii import main


if __name__ == '__main__':
main()
2 changes: 1 addition & 1 deletion doc/source/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Discover available make targets::
make help

Clean up previous build::

make clean

Build html documentation::
Expand Down
1 change: 0 additions & 1 deletion doc/source/_templates/indexsidebar.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@ <h3>Search mailing list archive</h3>
<input name="userquery" size="18" type="text" /> <input type="submit" value="Go" />
<input name="q" type="hidden" />
</form>

116 changes: 62 additions & 54 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@
try:
import nibabel
except ImportError:
raise RuntimeError('Need nibabel on Python PATH; consider "make htmldoc" '
'from nibabel root directory')
raise RuntimeError(
'Need nibabel on Python PATH; consider "make htmldoc" from nibabel root directory'
)

# -- General configuration ----------------------------------------------------

Expand All @@ -55,23 +56,24 @@
fobj.write(rel['long_description'])

# Load metadata from setup.cfg
with open(Path("../../pyproject.toml"), 'rb') as fobj:
with open(Path('../../pyproject.toml'), 'rb') as fobj:
pyproject = tomllib.load(fobj)
authors = pyproject["project"]["authors"][0]
authors = pyproject['project']['authors'][0]

# 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.doctest',
'sphinx.ext.intersphinx',
'sphinx.ext.todo',
'sphinx.ext.mathjax',
'sphinx.ext.inheritance_diagram',
'sphinx.ext.autosummary',
'texext.math_dollar', # has to go before numpydoc
'numpydoc',
'matplotlib.sphinxext.plot_directive',
]
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.doctest',
'sphinx.ext.intersphinx',
'sphinx.ext.todo',
'sphinx.ext.mathjax',
'sphinx.ext.inheritance_diagram',
'sphinx.ext.autosummary',
'texext.math_dollar', # has to go before numpydoc
'numpydoc',
'matplotlib.sphinxext.plot_directive',
]

# Autosummary always wants to use a `generated/` directory.
# We generate with `make api-stamp`
Expand All @@ -85,13 +87,13 @@
source_suffix = '.rst'

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

# The master toctree document.
master_doc = 'index'

# General information about the project.
project = u'NiBabel'
project = 'NiBabel'
copyright = f"2006-2022, {authors['name']} <{authors['email']}>"

# The version info for the project you're documenting, acts as replacement for
Expand All @@ -105,11 +107,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,32 +126,32 @@
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 --------------------------------------------------

# Set attributes for layout of inheritance diagrams
inheritance_graph_attrs = dict(rankdir="LR", size='"6.0, 8.0"', fontsize=14,
ratio='compress')
inheritance_node_attrs = dict(shape='ellipse', fontsize=14, height=0.75,
color='dodgerblue1', style='filled')
inheritance_graph_attrs = dict(rankdir='LR', size='"6.0, 8.0"', fontsize=14, ratio='compress')
inheritance_node_attrs = dict(
shape='ellipse', fontsize=14, height=0.75, color='dodgerblue1', style='filled'
)

# Flag to show todo items in rendered output
todo_include_todos = True
Expand All @@ -168,26 +170,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 +198,50 @@

# 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']}
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 +251,32 @@
# -- 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]).
latex_documents = [
('index', 'nibabel.tex', u'NiBabel Documentation', u'NiBabel Authors',
'manual')]
latex_documents = [('index', 'nibabel.tex', 'NiBabel Documentation', '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
1 change: 0 additions & 1 deletion doc/source/devel/biaps/biap_0001.rst
Original file line number Diff line number Diff line change
Expand Up @@ -297,4 +297,3 @@ How about the names in the proposal? ``is_proxy``; ``unproxy=True``?


.. vim: ft=rst

4 changes: 2 additions & 2 deletions doc/source/devel/biaps/biap_0003.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ From `adding nifti extensions`_:
* 4 = NIFTI_ECODE_AFNI = AFNI header attributes: The format of the AFNI
extension in the NIfTI-1.1 format is described at
http://nifti.nimh.nih.gov/nifti-1/AFNIextension1/
* 6 = NIFTI_ECODE_COMMENT = comment: arbitrary non-NUL ASCII text, with no
* 6 = NIFTI_ECODE_COMMENT = comment: arbitrary non-NUL ASCII text, with no
additional structure implied
* 8 = NIFTI_ECODE_XCEDE = XCEDE metadata:
http://www.nbirn.net/Resources/Users/Applications/xcede/index.htm
Expand Down Expand Up @@ -369,7 +369,7 @@ apply to the Cartesian product of the image axis values. For example, if the
values of ``applies_to`` == ``['slice', 'time']``, and the slice and time axes
in the array are lengths (6, 10) respectively, then the values apply to all
combinations of the 6 possible values for slice indices and the 10 possible
values for the time indices (ie apply to all 6x10=60 values). The axis metadata
values for the time indices (ie apply to all 6x10=60 values). The axis metadata
values in this case can be:

* a scalar. The value applies to every combination of (slice, time)
Expand Down
Loading