Skip to content

Commit

Permalink
Merge pull request #1655 from mathbunnyru/asalikhov/pre_commit_isort_…
Browse files Browse the repository at this point in the history
…reqs

Run pre-commit tools: isort, requirements-txt-fixer
  • Loading branch information
mathbunnyru committed Mar 17, 2022
2 parents f91b9ad + 591a09c commit 090bf5d
Show file tree
Hide file tree
Showing 29 changed files with 73 additions and 69 deletions.
15 changes: 12 additions & 3 deletions .pre-commit-config.yaml
Expand Up @@ -19,6 +19,13 @@ repos:
- id: pyupgrade
args: [--py39-plus]

# Automatically sort python imports
- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
args: [--profile, black]

# Autoformat: Python code
- repo: https://github.com/psf/black
rev: 22.1.0
Expand Down Expand Up @@ -53,9 +60,10 @@ 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-added-large-files
- id: end-of-file-fixer
- id: requirements-txt-fixer
- id: trailing-whitespace

# Lint: Dockerfile
- repo: https://github.com/hadolint/hadolint.git
Expand Down Expand Up @@ -108,12 +116,13 @@ repos:
- id: nbstripout

# nbQA provides tools from the Python ecosystem like
# pyupgrade, black, and flake8, adjusted for notebooks.
# pyupgrade, isort, black, and flake8, adjusted for notebooks.
- repo: https://github.com/nbQA-dev/nbQA
rev: 1.3.1
hooks:
- id: nbqa-pyupgrade
args: [--py39-plus]
- id: nbqa-isort
- id: nbqa-black
args: [--target-version=py39]
- id: nbqa-flake8
Expand Down
4 changes: 2 additions & 2 deletions base-notebook/jupyter_server_config.py
@@ -1,11 +1,11 @@
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
# mypy: ignore-errors
from jupyter_core.paths import jupyter_data_dir
import subprocess
import os
import stat
import subprocess

from jupyter_core.paths import jupyter_data_dir

c = get_config() # noqa: F821
c.ServerApp.ip = "0.0.0.0"
Expand Down
3 changes: 2 additions & 1 deletion tagging/create_manifests.py
Expand Up @@ -5,13 +5,14 @@
import datetime
import logging
import os

from docker.models.containers import Container

from .docker_runner import DockerRunner
from .get_taggers_and_manifests import get_taggers_and_manifests
from .git_helper import GitHelper
from .manifests import ManifestHeader, ManifestInterface


LOGGER = logging.getLogger(__name__)


Expand Down
6 changes: 3 additions & 3 deletions tagging/docker_runner.py
@@ -1,11 +1,11 @@
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
from typing import Optional
import logging
from types import TracebackType
from typing import Optional

import docker
from docker.models.containers import Container
import logging


LOGGER = logging.getLogger(__name__)

Expand Down
1 change: 1 addition & 0 deletions tagging/get_taggers_and_manifests.py
@@ -1,6 +1,7 @@
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
from typing import Optional

from .images_hierarchy import ALL_IMAGES
from .manifests import ManifestInterface
from .taggers import TaggerInterface
Expand Down
37 changes: 19 additions & 18 deletions tagging/images_hierarchy.py
Expand Up @@ -2,29 +2,30 @@
# Distributed under the terms of the Modified BSD License.
from dataclasses import dataclass, field
from typing import Optional

from .manifests import (
AptPackagesManifest,
CondaEnvironmentManifest,
JuliaPackagesManifest,
ManifestInterface,
RPackagesManifest,
SparkInfoManifest,
)
from .taggers import (
TaggerInterface,
SHATagger,
DateTagger,
UbuntuVersionTagger,
PythonVersionTagger,
JupyterNotebookVersionTagger,
JupyterLabVersionTagger,
HadoopVersionTagger,
JavaVersionTagger,
JuliaVersionTagger,
JupyterHubVersionTagger,
JupyterLabVersionTagger,
JupyterNotebookVersionTagger,
PythonVersionTagger,
RVersionTagger,
TensorflowVersionTagger,
JuliaVersionTagger,
SHATagger,
SparkVersionTagger,
HadoopVersionTagger,
JavaVersionTagger,
)
from .manifests import (
ManifestInterface,
CondaEnvironmentManifest,
AptPackagesManifest,
RPackagesManifest,
JuliaPackagesManifest,
SparkInfoManifest,
TaggerInterface,
TensorflowVersionTagger,
UbuntuVersionTagger,
)


Expand Down
3 changes: 2 additions & 1 deletion tagging/manifests.py
@@ -1,7 +1,8 @@
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
from plumbum.cmd import docker
from docker.models.containers import Container
from plumbum.cmd import docker

from .docker_runner import DockerRunner
from .git_helper import GitHelper

Expand Down
3 changes: 2 additions & 1 deletion tagging/tag_image.py
Expand Up @@ -3,12 +3,13 @@
# Distributed under the terms of the Modified BSD License.
import argparse
import logging

from plumbum.cmd import docker

from .docker_runner import DockerRunner
from .get_taggers_and_manifests import get_taggers_and_manifests
from .github_set_env import github_set_env


LOGGER = logging.getLogger(__name__)


Expand Down
4 changes: 3 additions & 1 deletion tagging/taggers.py
@@ -1,9 +1,11 @@
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
from datetime import datetime

from docker.models.containers import Container
from .git_helper import GitHelper

from .docker_runner import DockerRunner
from .git_helper import GitHelper


def _get_program_version(container: Container, program: str) -> str:
Expand Down
3 changes: 1 addition & 2 deletions tests/all-spark-notebook/test_spark_notebooks.py
Expand Up @@ -2,10 +2,9 @@
# Distributed under the terms of the Modified BSD License.

import logging

import pytest # type: ignore
from pathlib import Path

import pytest # type: ignore
from conftest import TrackedContainer

LOGGER = logging.getLogger(__name__)
Expand Down
3 changes: 1 addition & 2 deletions tests/base-notebook/test_container_options.py
@@ -1,12 +1,11 @@
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import logging
import pathlib
import time
import logging

import pytest # type: ignore
import requests

from conftest import TrackedContainer, find_free_port

LOGGER = logging.getLogger(__name__)
Expand Down
1 change: 0 additions & 1 deletion tests/base-notebook/test_outdated.py
Expand Up @@ -5,7 +5,6 @@

import pytest # type: ignore
from conftest import TrackedContainer

from package_helper import CondaPackageHelper

LOGGER = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion tests/base-notebook/test_package_managers.py
Expand Up @@ -2,8 +2,8 @@
# Distributed under the terms of the Modified BSD License.

import logging
import pytest # type: ignore

import pytest # type: ignore
from conftest import TrackedContainer

LOGGER = logging.getLogger(__name__)
Expand Down
3 changes: 1 addition & 2 deletions tests/base-notebook/test_packages.py
Expand Up @@ -38,11 +38,10 @@
"""

import logging
from typing import Callable, Iterable

import pytest # type: ignore
from conftest import TrackedContainer
from typing import Callable, Iterable

from package_helper import CondaPackageHelper

LOGGER = logging.getLogger(__name__)
Expand Down
3 changes: 1 addition & 2 deletions tests/base-notebook/test_python.py
Expand Up @@ -2,9 +2,8 @@
# Distributed under the terms of the Modified BSD License.
import logging

from packaging import version # type: ignore

from conftest import TrackedContainer
from packaging import version # type: ignore

LOGGER = logging.getLogger(__name__)

Expand Down
4 changes: 2 additions & 2 deletions tests/base-notebook/test_start_container.py
Expand Up @@ -2,11 +2,11 @@
# Distributed under the terms of the Modified BSD License.

import logging
import time
from typing import Optional

import pytest # type: ignore
import requests
import time

from conftest import TrackedContainer, find_free_port

LOGGER = logging.getLogger(__name__)
Expand Down
10 changes: 4 additions & 6 deletions tests/conftest.py
@@ -1,19 +1,17 @@
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
from contextlib import closing
import os
import logging
import os
import socket
from contextlib import closing
from typing import Any, Optional

import docker
from docker.models.containers import Container
import pytest # type: ignore
import requests

from urllib3.util.retry import Retry
from docker.models.containers import Container
from requests.adapters import HTTPAdapter

from urllib3.util.retry import Retry

LOGGER = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion tests/minimal-notebook/data/notebook_math.ipynb
Expand Up @@ -27,7 +27,7 @@
},
"outputs": [],
"source": [
"from sympy import init_printing, symbols, sin, diff, integrate"
"from sympy import diff, init_printing, integrate, sin, symbols"
]
},
{
Expand Down
3 changes: 1 addition & 2 deletions tests/minimal-notebook/test_nbconvert.py
Expand Up @@ -2,10 +2,9 @@
# Distributed under the terms of the Modified BSD License.

import logging

import pytest # type: ignore
from pathlib import Path

import pytest # type: ignore
from conftest import TrackedContainer

LOGGER = logging.getLogger(__name__)
Expand Down
9 changes: 4 additions & 5 deletions tests/package_helper.py
Expand Up @@ -22,17 +22,16 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

import json
import logging
import re
from collections import defaultdict
from itertools import chain
import logging
import json
from typing import Any, Optional
from docker.models.containers import Container

from tabulate import tabulate

from conftest import TrackedContainer
from docker.models.containers import Container
from tabulate import tabulate

LOGGER = logging.getLogger(__name__)

Expand Down
1 change: 0 additions & 1 deletion tests/pyspark-notebook/test_spark.py
Expand Up @@ -4,7 +4,6 @@

from conftest import TrackedContainer


LOGGER = logging.getLogger(__name__)


Expand Down
4 changes: 1 addition & 3 deletions tests/run_tests.py
Expand Up @@ -5,10 +5,8 @@
import logging

import plumbum
from plumbum.cmd import pytest

from images_hierarchy import get_test_dirs

from plumbum.cmd import pytest

LOGGER = logging.getLogger(__name__)

Expand Down
6 changes: 4 additions & 2 deletions tests/scipy-notebook/data/cython/setup.py
@@ -1,4 +1,6 @@
from setuptools import setup
from Cython.Build import cythonize
# These lines are not sorted by isort on purpose
# see: https://stackoverflow.com/a/53356077/4881441
from setuptools import setup # isort:skip
from Cython.Build import cythonize # isort:skip

setup(ext_modules=cythonize("helloworld.pyx"))
3 changes: 2 additions & 1 deletion tests/scipy-notebook/data/matplotlib/matplotlib_1.py
@@ -1,11 +1,12 @@
# Matplotlib: Create a simple plot example.
# Refs: https://matplotlib.org/stable/gallery/lines_bars_and_markers/simple_plot.html

import os

# Optional test with [Matplotlib Jupyter Integration](https://github.com/matplotlib/ipympl)
# %matplotlib widget
import matplotlib.pyplot as plt
import numpy as np
import os

# Data for plotting
t = np.arange(0.0, 2.0, 0.01)
Expand Down
3 changes: 2 additions & 1 deletion tests/scipy-notebook/data/matplotlib/matplotlib_fonts_1.py
@@ -1,7 +1,8 @@
# Matplotlib: Test tex fonts
import os

import matplotlib
import matplotlib.pyplot as plt
import os

matplotlib.rcParams["pgf.texsystem"] = "pdflatex"
matplotlib.rcParams.update(
Expand Down
1 change: 0 additions & 1 deletion tests/scipy-notebook/test_extensions.py
Expand Up @@ -3,7 +3,6 @@
import logging

import pytest # type: ignore

from conftest import TrackedContainer

LOGGER = logging.getLogger(__name__)
Expand Down

0 comments on commit 090bf5d

Please sign in to comment.