Skip to content

Commit

Permalink
Lint codebase with additional style restrictions (#970)
Browse files Browse the repository at this point in the history
* Add more flake8 extensions.

* Drop flake8-warnings.

* Start addressing issues.

* Whoops!

* Keep going.

* More work.

* Ran pre-commit in all files

* Added flynt hook for f strings

* Changed format for f-string in metrics/collect

* Fixed all issues in metrics folder

* Fixed metrics unit test

* Undo lowercase from dictionary keys

* Lowercase the variable I forgot

* Finished with metrics and io

* Added pydocstringformatter to pre-commit and ran it

* Changed max number of summary lines to 2

* Added numpy doctstring style to precommit

* Update pyproject.toml

* Removed the numpydoc option because it was driving me crazy

* Fixed docstrings in bibtex.py

* Did all reporting

* Fixed workflows

* Fixed utils

* Fixed a couple of style issue and excluded D from tests

* Did all the selection folder

Also updated pydocstringformatter to only allow 1 summary line.

* Everything except tests should be done by now

* That should be all!

* Fixed error

* Update link to black pre-commit repo

* Fix LaTeX equation errors in PCA decomposition docstring

* Use r and single slash

* Fix double slash in combine

* Delete _utils.py

* Update tedana/reporting/static_figures.py

Co-authored-by: Dan Handwerker <7406227+handwerkerd@users.noreply.github.com>

---------

Co-authored-by: Eneko Uruñuela <e.urunuela@icloud.com>
Co-authored-by: Dan Handwerker <7406227+handwerkerd@users.noreply.github.com>
  • Loading branch information
3 people committed Oct 27, 2023
1 parent b11d254 commit b139386
Show file tree
Hide file tree
Showing 67 changed files with 808 additions and 906 deletions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/issue_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ If you foresee them in a particular order or priority, please use numbering
-->
### Next Steps

<!--
<!--
Thank you for submitting your issue!
If you do not receive a response within a calendar week, please post a comment on this issue to catch our attention.
If you do not receive a response within a calendar week, please post a comment on this issue to catch our attention.
Some issues may not be resolved right away due to the volunteer nature of the project; thank you for your patience!
-->
16 changes: 13 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/psf/black
rev: 23.9.1
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.10.0
hooks:
- id: black
files: ^tedana/
Expand All @@ -16,3 +16,13 @@ repos:
hooks:
- id: isort
files: ^tedana/
- repo: https://github.com/ikamensh/flynt/
rev: 1.0.1
hooks:
- id: flynt
files: ^tedana/
- repo: https://github.com/DanielNoord/pydocstringformatter
rev: v0.7.3
hooks:
- id: pydocstringformatter
files: ^tedana/
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ reported by contacting our
and [Stefano Moia](https://github.com/smoia).
Confidentiality will be respected in reporting.
The Code of Conduct Enforcement Team any take any action they deem
necessary for the safety of the `tedana` community, including but not
necessary for the safety of the `tedana` community, including but not
limited to:

* facilitating a conversation between the two parties involved in the violation of the code of conduct
Expand Down
18 changes: 9 additions & 9 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.

Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
Expand Down Expand Up @@ -111,7 +111,7 @@ modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.

GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

Expand Down Expand Up @@ -158,7 +158,7 @@ Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.

2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
Expand Down Expand Up @@ -216,7 +216,7 @@ instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.

Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
Expand Down Expand Up @@ -267,7 +267,7 @@ Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.

6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
Expand Down Expand Up @@ -329,7 +329,7 @@ restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.

7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
Expand Down Expand Up @@ -370,7 +370,7 @@ subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.

11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
Expand Down Expand Up @@ -422,7 +422,7 @@ conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.

14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
Expand Down Expand Up @@ -456,7 +456,7 @@ SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.

END OF TERMS AND CONDITIONS

How to Apply These Terms to Your New Libraries

If you develop a new library, and you want it to be of the greatest
Expand Down
4 changes: 2 additions & 2 deletions docs/_static/decision_tree_kundu.tex
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
\pagecolor{white}

%-------------------------defining colorblind friendly colors
% Using pale color scheme in Figure 6
% Using pale color scheme in Figure 6
% by Paul Tol https://personal.sron.nl/~pault/
\definecolor{cbblue}{HTML}{BBCCEE}
\definecolor{cbcyan}{HTML}{CCEEFF}
Expand All @@ -15,7 +15,7 @@
\definecolor{cbred}{HTML}{FFCCCC}
\definecolor{cbgrey}{HTML}{DDDDDD}

% -------------------------defining nodes
% -------------------------defining nodes
\tikzstyle{input} = [trapezium, trapezium left angle =80, trapezium right angle = 100,
minimum width= 3cm, minimum height=0.5cm, text centered, draw=black, fill=cbblue]
\tikzstyle{process} = [rectangle, minimum width = 3cm, minimum height = 1cm,
Expand Down
6 changes: 3 additions & 3 deletions docs/_static/decision_tree_legend.tex
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
\pagecolor{white}

%-------------------------defining colorblind friendly colors
% Using pale color scheme in Figure 6
% Using pale color scheme in Figure 6
% by Paul Tol https://personal.sron.nl/~pault/
\definecolor{cbblue}{HTML}{BBCCEE}
\definecolor{cbcyan}{HTML}{CCEEFF}
Expand All @@ -15,7 +15,7 @@
\definecolor{cbred}{HTML}{FFCCCC}
\definecolor{cbgrey}{HTML}{DDDDDD}

% -------------------------defining nodes
% -------------------------defining nodes
\tikzstyle{input} = [trapezium, trapezium left angle =80, trapezium right angle = 100,
minimum width= 3cm, minimum height=0.5cm, text centered, draw=black, fill=cbblue]
\tikzstyle{process} = [rectangle, minimum width = 3cm, minimum height = 0cm,
Expand Down Expand Up @@ -54,4 +54,4 @@


\end{tikzpicture}
\end{document}
\end{document}
4 changes: 2 additions & 2 deletions docs/_static/decision_tree_minimal.tex
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
\pagecolor{white}

%-------------------------defining colorblind friendly colors
% Using pale color scheme in Figure 6
% Using pale color scheme in Figure 6
% by Paul Tol https://personal.sron.nl/~pault/
\definecolor{cbblue}{HTML}{BBCCEE}
\definecolor{cbcyan}{HTML}{CCEEFF}
Expand All @@ -15,7 +15,7 @@
\definecolor{cbred}{HTML}{FFCCCC}
\definecolor{cbgrey}{HTML}{DDDDDD}

% -------------------------defining nodes
% -------------------------defining nodes
\tikzstyle{input} = [trapezium, trapezium left angle =80, trapezium right angle = 100,
minimum width= 3cm, minimum height=0.5cm, text centered, draw=black, fill=cbblue]
\tikzstyle{process} = [rectangle, minimum width = 3cm, minimum height = 1cm,
Expand Down
2 changes: 1 addition & 1 deletion docs/building_decision_trees.rst
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ that is used to check whether results are plausible & can help avoid mistakes.
A narrative description of the tree that could be used in report logging.
This should include any citations, which must be included in the
`references BibTeX file`_.

.. _references BibTeX file: https://github.com/ME-ICA/tedana/blob/main/tedana/resources/references.bib

- necessary_metrics
Expand Down
2 changes: 1 addition & 1 deletion docs/included_decision_trees.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ a component was given a specific classification.
Each step in the flow chart is labeled with a ``node`` number.
If ``tedana`` is run using one of these trees, those node
numbers will match the numbers in the ``ICA status table`` and the
``ICA decision tree`` that are described in
``ICA decision tree`` that are described in
:ref:`output-filename-descriptions`. These node numbers can be used
to see when in the process a component's classifiation changed.

Expand Down
2 changes: 1 addition & 1 deletion docs/multi-echo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ For more details, see the `fmriprep workflows page`_ and :ref:`collecting fMRIPr

.. _fmriprep workflows page: https://fmriprep.readthedocs.io/en/stable/workflows.html

`fmrwhy`_ runs BIDS-compatible fMRI analysis with SPM12 and supports multi-echo data,
`fmrwhy`_ runs BIDS-compatible fMRI analysis with SPM12 and supports multi-echo data,
but it is no longer being actively maintained.

.. _fmrwhy: https://fmrwhy.readthedocs.io
Expand Down
4 changes: 2 additions & 2 deletions docs/outputs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ future processing. ``tedana`` allows for multiple file naming conventions. The k
and naming options for each convention that can be set using the ``--convention`` option
are in `outputs.json`_. The output of ``tedana`` also includes a file called
``registry.json`` or ``desc-tedana_registry.json`` that includes the keys and the matching
file names for the output. The table below lists both these keys and the default
file names for the output. The table below lists both these keys and the default
"BIDS Derivatives" file names.

.. _outputs.json: https://github.com/ME-ICA/tedana/blob/main/tedana/resources/config/outputs.json
Expand Down Expand Up @@ -399,7 +399,7 @@ component (selected in the summary view, see below). It includes three different
(selected in the summary view). The x-axis represents time (in units of TR and seconds),
and the y-axis represents signal levels (in arbitrary units).
Finally, the color of the trace informs us about the component classification status.
Plausibly BOLD-weighted components might have responses that follow the task design,
Plausibly BOLD-weighted components might have responses that follow the task design,
while components that are less likely to be BOLD-weighted might have large signal
spikes or slow drifts. If a high variance component time series initially has a few
very high magnitude volumes, that is a sign non-steady state volumes were not removed
Expand Down
4 changes: 2 additions & 2 deletions docs/zenodo.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ String.prototype.endsWith = function(suffix) {
};

function getZenodoIDFromTag(conceptRecID, tagName, callback) {
getContent('https://zenodo.org/api/records/?q=conceptrecid:' + conceptRecID + '%20AND%20related.identifier:*github*' + tagName + '&all_versions&sort=-version',
getContent('https://zenodo.org/api/records/?q=conceptrecid:' + conceptRecID + '%20AND%20related.identifier:*github*' + tagName + '&all_versions&sort=-version',
'application/json',
function(err, data) {
if (err !== null) {
Expand All @@ -42,7 +42,7 @@ function getZenodoIDFromTag(conceptRecID, tagName, callback) {
}

function getLatestIDFromconceptID(conceptRecID, callback) {
getContent('https://zenodo.org/api/records/' + conceptRecID,
getContent('https://zenodo.org/api/records/' + conceptRecID,
'application/json',
function(err, data) {
if (err !== null) {
Expand Down
11 changes: 11 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,14 @@ tests = [
"codecov",
"coverage",
"flake8>=3.7",
"flake8-absolute-import",
"flake8-black",
"flake8-docstrings",
"flake8-isort",
"flake8-pyproject",
"flake8-unused-arguments",
"flake8-use-fstring",
"pep8-naming",
"pytest",
"pytest-cov>=4.0.0",
"requests",
Expand Down Expand Up @@ -130,9 +135,15 @@ exclude = [
ignore = ["E203", "E402", "W503"]
per-file-ignores = [
"*/__init__.py: F401",
"tedana/tests/*: D",
]
docstring-convention = "numpy"

[tool.pydocstringformatter]
write = true
strip-whitespaces = true
max-summary-lines = 1

[tool.coverage.run]
branch = true
omit = [
Expand Down
2 changes: 1 addition & 1 deletion tedana/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft=python sts=4 ts=4 sw=4 et:
"""tedana: A Python package for TE-dependent analysis of multi-echo data."""
"""Tedana: A Python package for TE-dependent analysis of multi-echo data."""
import warnings

from tedana.__about__ import __copyright__, __credits__, __packagename__, __version__
Expand Down
6 changes: 2 additions & 4 deletions tedana/bibtex.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""
Utilities for tedana package
"""
"""Utilities for managing the tedana bibliography."""
import logging
import os.path as op
import re
Expand All @@ -27,7 +25,7 @@ def find_braces(string):
Returns
-------
:obj:`list` of :obj:`tuple` of :obj:`int`
: obj:`list` of :obj:`tuple` of :obj:`int`
A list of two-element tuples of indices of matched braces.
"""
toret = {}
Expand Down
Loading

0 comments on commit b139386

Please sign in to comment.