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

add isort workflow #1538

Merged
merged 28 commits into from
May 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
8713291
add isort workflow
mirpedrol May 3, 2022
c741cd1
add isort to lint-code workflow
mirpedrol May 5, 2022
153c0e0
run isort
mirpedrol May 17, 2022
89f4f95
merge dev branch
mirpedrol May 17, 2022
281e550
run isort
mirpedrol May 17, 2022
4a05501
fix isort with black
mirpedrol May 17, 2022
a8bebd8
apply review comments, move configuration to pyproject.toml
mirpedrol May 19, 2022
8fb94cf
add isort to CHANGELOG
mirpedrol May 19, 2022
d3f8099
add linting section to CHANGELOG
mirpedrol May 19, 2022
2083c38
add multi_line_output
mirpedrol May 20, 2022
bfade7f
run isort with multi_line_output
mirpedrol May 20, 2022
7733200
try to fix linting error
mirpedrol May 20, 2022
f733919
remove unnecessary requirements.txt installation
mirpedrol May 20, 2022
608bd08
add isort to fix-linting.yml
mirpedrol May 20, 2022
64c58ef
fix isort from fix-linting
mirpedrol May 20, 2022
5321c35
remove unnecessary configuration
mirpedrol May 23, 2022
e5f5375
remove configuration from fix-linting
mirpedrol May 24, 2022
f2459b8
Merge branch 'dev' into isort
ewels May 24, 2022
f82ea0a
fix linting
mirpedrol May 24, 2022
83e4c66
Remove isort installation from workflow
mirpedrol May 24, 2022
f3d0b17
add isort to requirements-dev.txt
mirpedrol May 24, 2022
1b6a49b
remove isort installation from fix-linting.yml
mirpedrol May 24, 2022
3f6a7e2
add isort documentation to CONTRIBUTING.md
mirpedrol May 25, 2022
abf0796
fix docs type
mirpedrol May 25, 2022
fb36840
Add isort badge
fabianegli May 25, 2022
d487e35
remove effect description
mirpedrol May 25, 2022
7fa3baa
Merge branch 'dev' into isort
fabianegli May 25, 2022
b655e6b
Merge branch 'dev' into isort
fabianegli May 25, 2022
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
22 changes: 21 additions & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ Then install your local fork of nf-core/tools:
pip install -e .
```

## Code formatting with Black
## Code formatting

### Black

All Python code in nf-core/tools must be passed through the [Black Python code formatter](https://black.readthedocs.io/en/stable/).
This ensures a harmonised code formatting style throughout the package, from all contributors.
Expand All @@ -51,6 +53,24 @@ You can also set it up to run when you [make a commit](https://black.readthedocs
There is an automated CI check that runs when you open a pull-request to nf-core/tools that will fail if
any code does not adhere to Black formatting.

### isort

All Python code must also be passed through [isort](https://pycqa.github.io/isort/index.html).
This ensures a harmonised imports throughout the package, from all contributors.

To run isort on the command line recursively on the whole repository you can use:

```bash
isort .
```

isort also has [plugins for most common editors](https://github.com/pycqa/isort/wiki/isort-Plugins)
to automatically format code when you hit save.
Or [version control integration](https://pycqa.github.io/isort/docs/configuration/pre-commit.html) to set it up to run when you make a commit.

There is an automated CI check that runs when you open a pull-request to nf-core/tools that will fail if
any code does not adhere to isort formatting.

## API Documentation

We aim to write function docstrings according to the [Google Python style-guide](https://github.com/google/styleguide/blob/gh-pages/pyguide.md#38-comments-and-docstrings). These are used to automatically generate package documentation on the nf-core website using Sphinx.
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/fix-linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ jobs:
# Override to remove the default --check flag so that we make changes
options: "--color"

- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: python-isort
uses: isort/isort-action@v0.1.0
with:
isortVersion: "latest"
requirementsFiles: "requirements.txt requirements-dev.txt"

- name: Commit & push changes
run: |
git config user.email "core@nf-co.re"
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/lint-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,19 @@ jobs:
Thanks again for your contribution!
repo-token: ${{ secrets.GITHUB_TOKEN }}
allow-repeats: false

isort:
runs-on: ubuntu-latest
steps:
- name: Check out source-code repository
uses: actions/checkout@v2

- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: python-isort
uses: isort/isort-action@v0.1.0
ewels marked this conversation as resolved.
Show resolved Hide resolved
with:
isortVersion: "latest"
requirementsFiles: "requirements.txt requirements-dev.txt"
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@

- Fix a bug in the regex extracting the version from biocontainers URLs [#1596](https://github.com/nf-core/tools/pull/1596)

### Linting

- Add isort configuration and GitHub workflow ([#1538](https://github.com/nf-core/tools/pull/1538))

## [v2.4.1 - Cobolt Koala Patch](https://github.com/nf-core/tools/releases/tag/2.4) - [2022-05-16]

- Patch release to try to fix the template sync ([#1585](https://github.com/nf-core/tools/pull/1585))
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[![Python tests](https://github.com/nf-core/tools/workflows/Python%20tests/badge.svg?branch=master&event=push)](https://github.com/nf-core/tools/actions?query=workflow%3A%22Python+tests%22+branch%3Amaster)
[![codecov](https://codecov.io/gh/nf-core/tools/branch/master/graph/badge.svg)](https://codecov.io/gh/nf-core/tools)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)

[![install with Bioconda](https://img.shields.io/badge/install%20with-bioconda-brightgreen.svg)](https://bioconda.github.io/recipes/nf-core/README.html)
[![install with PyPI](https://img.shields.io/badge/install%20with-PyPI-blue.svg)](https://pypi.org/project/nf-core/)
Expand Down
1 change: 1 addition & 0 deletions docs/api/make_lint_md.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import fnmatch
import os

import nf_core.lint
import nf_core.modules.lint

Expand Down
5 changes: 3 additions & 2 deletions nf_core/__main__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#!/usr/bin/env python
""" nf-core: Helper tools for use with nf-core Nextflow pipelines. """
from rich import print
import logging
import os
import re
import sys

import rich.console
import rich.logging
import rich.traceback
import rich_click as click
import sys
from rich import print

import nf_core
import nf_core.bump_version
Expand Down
4 changes: 3 additions & 1 deletion nf_core/bump_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
import logging
import os
import re
import rich.console
import sys

import rich.console

import nf_core.utils

log = logging.getLogger(__name__)
Expand Down
9 changes: 5 additions & 4 deletions nf_core/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@
"""Creates a nf-core pipeline matching the current
organization's specification based on a template.
"""
from genericpath import exists
import git
import imghdr
import jinja2
import logging
import os
import pathlib
import random
import requests
import shutil
import sys
import time

import git
import jinja2
import requests
from genericpath import exists

import nf_core

log = logging.getLogger(__name__)
Expand Down
15 changes: 8 additions & 7 deletions nf_core/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,23 @@

from __future__ import print_function

from io import BytesIO
import logging
import concurrent.futures
import hashlib
import logging
import os
import questionary
import re
import requests
import requests_cache
import shutil
import subprocess
import sys
import tarfile
import concurrent.futures
from io import BytesIO
from zipfile import ZipFile

import questionary
import requests
import requests_cache
import rich
import rich.progress
from zipfile import ZipFile

import nf_core
import nf_core.list
Expand Down
12 changes: 7 additions & 5 deletions nf_core/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,23 @@
""" Launch a pipeline, interactively collecting params """

from __future__ import print_function
from rich.console import Console
from rich.markdown import Markdown
from rich.prompt import Confirm

import copy
import json
import logging
import os
import questionary
import re
import subprocess
import webbrowser

import questionary
import requests
from rich.console import Console
from rich.markdown import Markdown
from rich.prompt import Confirm

import nf_core.schema, nf_core.utils
import nf_core.schema
import nf_core.utils

log = logging.getLogger(__name__)

Expand Down
5 changes: 3 additions & 2 deletions nf_core/licences.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@

from __future__ import print_function

import logging
import json
import logging
import os
import re

import requests
import yaml
import rich.console
import rich.table
import yaml

import nf_core.utils

Expand Down
15 changes: 8 additions & 7 deletions nf_core/lint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@
the nf-core community guidelines.
"""

from rich.markdown import Markdown
from rich.table import Table
from rich.panel import Panel
from rich.console import group
import datetime
import git
import json
import logging
import re

import git
import rich
import rich.progress
from rich.console import group
from rich.markdown import Markdown
from rich.panel import Panel
from rich.table import Table

import nf_core.utils
import nf_core.lint_utils
import nf_core.modules.lint
import nf_core.utils
from nf_core import __version__
from nf_core.lint_utils import console
from nf_core.utils import plural_s as _s
Expand Down Expand Up @@ -160,9 +161,9 @@ class PipelineLint(nf_core.utils.Pipeline):
from .pipeline_name_conventions import pipeline_name_conventions
from .pipeline_todos import pipeline_todos
from .readme import readme
from .schema_description import schema_description
from .schema_lint import schema_lint
from .schema_params import schema_params
from .schema_description import schema_description
from .template_strings import template_strings
from .version_consistency import version_consistency

Expand Down
1 change: 1 addition & 0 deletions nf_core/lint/actions_awsfulltest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python

import os

import yaml


Expand Down
1 change: 1 addition & 0 deletions nf_core/lint/actions_awstest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python

import os

import yaml


Expand Down
1 change: 1 addition & 0 deletions nf_core/lint/actions_ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import os
import re

import yaml


Expand Down
9 changes: 5 additions & 4 deletions nf_core/lint/actions_schema_validation.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#!/usr/bin/env python

import logging
import yaml
import glob
import json
import jsonschema
import logging
import os
import glob

import jsonschema
import requests
import yaml


def actions_schema_validation(self):
Expand Down
4 changes: 2 additions & 2 deletions nf_core/lint/merge_markers.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env python

import fnmatch
import io
import logging
import os
import io
import fnmatch

import nf_core.utils

Expand Down
1 change: 1 addition & 0 deletions nf_core/lint/modules_json.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python

from logging import warn

from nf_core.modules.modules_command import ModuleCommand


Expand Down
1 change: 1 addition & 0 deletions nf_core/lint/multiqc_config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python

import os

import yaml


Expand Down
4 changes: 2 additions & 2 deletions nf_core/lint/nextflow_config.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env python

import re
import os
import logging
import os
import re

log = logging.getLogger(__name__)

Expand Down
4 changes: 2 additions & 2 deletions nf_core/lint/pipeline_todos.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env python

import fnmatch
import io
import logging
import os
import io
import fnmatch

log = logging.getLogger(__name__)

Expand Down
1 change: 1 addition & 0 deletions nf_core/lint/schema_description.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python

from logging import warn

import nf_core.schema


Expand Down
4 changes: 3 additions & 1 deletion nf_core/lint/schema_lint.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/usr/bin/env python

import logging
import nf_core.schema

import jsonschema

import nf_core.schema


def schema_lint(self):
"""Pipeline schema syntax
Expand Down
3 changes: 2 additions & 1 deletion nf_core/lint_utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import logging

import rich
from rich.console import Console
from rich.table import Table
import logging

import nf_core.utils
from nf_core.utils import plural_s as _s
Expand Down
Loading