Skip to content

Commit

Permalink
Merge pull request #1538 from mirpedrol/isort
Browse files Browse the repository at this point in the history
add isort workflow
  • Loading branch information
ewels authored May 30, 2022
2 parents a91cc78 + b655e6b commit f63df8c
Show file tree
Hide file tree
Showing 79 changed files with 363 additions and 236 deletions.
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/[email protected]
with:
isortVersion: "latest"
requirementsFiles: "requirements.txt requirements-dev.txt"

- name: Commit & push changes
run: |
git config user.email "[email protected]"
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/[email protected]
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 [#1598](https://github.com/nf-core/tools/pull/1598)

### 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

0 comments on commit f63df8c

Please sign in to comment.