Run pre-commit tools: isort, requirements-txt-fixer

This commit is contained in:
Ayaz Salikhov
2022-03-16 14:48:23 +02:00
parent 25add573f9
commit 2f201a4b81
29 changed files with 72 additions and 69 deletions

View File

@@ -19,6 +19,13 @@ repos:
- id: pyupgrade - id: pyupgrade
args: [--py39-plus] 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 # Autoformat: Python code
- repo: https://github.com/psf/black - repo: https://github.com/psf/black
rev: 22.1.0 rev: 22.1.0
@@ -53,9 +60,11 @@ repos:
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0 rev: v4.1.0
hooks: hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-added-large-files - id: check-added-large-files
- id: end-of-file-fixer
- id: requirements-txt-fixer
args: [requirements-dev.txt, requirements-docs.txt]
- id: trailing-whitespace
# Lint: Dockerfile # Lint: Dockerfile
- repo: https://github.com/hadolint/hadolint.git - repo: https://github.com/hadolint/hadolint.git
@@ -108,12 +117,13 @@ repos:
- id: nbstripout - id: nbstripout
# nbQA provides tools from the Python ecosystem like # 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 - repo: https://github.com/nbQA-dev/nbQA
rev: 1.3.1 rev: 1.3.1
hooks: hooks:
- id: nbqa-pyupgrade - id: nbqa-pyupgrade
args: [--py39-plus] args: [--py39-plus]
- id: nbqa-isort
- id: nbqa-black - id: nbqa-black
args: [--target-version=py39] args: [--target-version=py39]
- id: nbqa-flake8 - id: nbqa-flake8

View File

@@ -1,11 +1,11 @@
# Copyright (c) Jupyter Development Team. # Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License. # Distributed under the terms of the Modified BSD License.
# mypy: ignore-errors # mypy: ignore-errors
from jupyter_core.paths import jupyter_data_dir
import subprocess
import os import os
import stat import stat
import subprocess
from jupyter_core.paths import jupyter_data_dir
c = get_config() # noqa: F821 c = get_config() # noqa: F821
c.ServerApp.ip = "0.0.0.0" c.ServerApp.ip = "0.0.0.0"

View File

@@ -5,13 +5,14 @@ import argparse
import datetime import datetime
import logging import logging
import os import os
from docker.models.containers import Container from docker.models.containers import Container
from .docker_runner import DockerRunner from .docker_runner import DockerRunner
from .get_taggers_and_manifests import get_taggers_and_manifests from .get_taggers_and_manifests import get_taggers_and_manifests
from .git_helper import GitHelper from .git_helper import GitHelper
from .manifests import ManifestHeader, ManifestInterface from .manifests import ManifestHeader, ManifestInterface
LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__)

View File

@@ -1,11 +1,11 @@
# Copyright (c) Jupyter Development Team. # Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License. # Distributed under the terms of the Modified BSD License.
from typing import Optional import logging
from types import TracebackType from types import TracebackType
from typing import Optional
import docker import docker
from docker.models.containers import Container from docker.models.containers import Container
import logging
LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__)

View File

@@ -1,6 +1,7 @@
# Copyright (c) Jupyter Development Team. # Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License. # Distributed under the terms of the Modified BSD License.
from typing import Optional from typing import Optional
from .images_hierarchy import ALL_IMAGES from .images_hierarchy import ALL_IMAGES
from .manifests import ManifestInterface from .manifests import ManifestInterface
from .taggers import TaggerInterface from .taggers import TaggerInterface

View File

@@ -2,29 +2,30 @@
# Distributed under the terms of the Modified BSD License. # Distributed under the terms of the Modified BSD License.
from dataclasses import dataclass, field from dataclasses import dataclass, field
from typing import Optional from typing import Optional
from .manifests import (
AptPackagesManifest,
CondaEnvironmentManifest,
JuliaPackagesManifest,
ManifestInterface,
RPackagesManifest,
SparkInfoManifest,
)
from .taggers import ( from .taggers import (
TaggerInterface,
SHATagger,
DateTagger, DateTagger,
UbuntuVersionTagger,
PythonVersionTagger,
JupyterNotebookVersionTagger,
JupyterLabVersionTagger,
JupyterHubVersionTagger,
RVersionTagger,
TensorflowVersionTagger,
JuliaVersionTagger,
SparkVersionTagger,
HadoopVersionTagger, HadoopVersionTagger,
JavaVersionTagger, JavaVersionTagger,
) JuliaVersionTagger,
from .manifests import ( JupyterHubVersionTagger,
ManifestInterface, JupyterLabVersionTagger,
CondaEnvironmentManifest, JupyterNotebookVersionTagger,
AptPackagesManifest, PythonVersionTagger,
RPackagesManifest, RVersionTagger,
JuliaPackagesManifest, SHATagger,
SparkInfoManifest, SparkVersionTagger,
TaggerInterface,
TensorflowVersionTagger,
UbuntuVersionTagger,
) )

View File

@@ -1,7 +1,8 @@
# Copyright (c) Jupyter Development Team. # Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License. # Distributed under the terms of the Modified BSD License.
from plumbum.cmd import docker
from docker.models.containers import Container from docker.models.containers import Container
from plumbum.cmd import docker
from .docker_runner import DockerRunner from .docker_runner import DockerRunner
from .git_helper import GitHelper from .git_helper import GitHelper

View File

@@ -3,12 +3,13 @@
# Distributed under the terms of the Modified BSD License. # Distributed under the terms of the Modified BSD License.
import argparse import argparse
import logging import logging
from plumbum.cmd import docker from plumbum.cmd import docker
from .docker_runner import DockerRunner from .docker_runner import DockerRunner
from .get_taggers_and_manifests import get_taggers_and_manifests from .get_taggers_and_manifests import get_taggers_and_manifests
from .github_set_env import github_set_env from .github_set_env import github_set_env
LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__)

View File

@@ -1,9 +1,11 @@
# Copyright (c) Jupyter Development Team. # Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License. # Distributed under the terms of the Modified BSD License.
from datetime import datetime from datetime import datetime
from docker.models.containers import Container from docker.models.containers import Container
from .git_helper import GitHelper
from .docker_runner import DockerRunner from .docker_runner import DockerRunner
from .git_helper import GitHelper
def _get_program_version(container: Container, program: str) -> str: def _get_program_version(container: Container, program: str) -> str:

View File

@@ -2,10 +2,9 @@
# Distributed under the terms of the Modified BSD License. # Distributed under the terms of the Modified BSD License.
import logging import logging
import pytest # type: ignore
from pathlib import Path from pathlib import Path
import pytest # type: ignore
from conftest import TrackedContainer from conftest import TrackedContainer
LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__)

View File

@@ -1,12 +1,11 @@
# Copyright (c) Jupyter Development Team. # Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License. # Distributed under the terms of the Modified BSD License.
import logging
import pathlib import pathlib
import time import time
import logging
import pytest # type: ignore import pytest # type: ignore
import requests import requests
from conftest import TrackedContainer, find_free_port from conftest import TrackedContainer, find_free_port
LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__)

View File

@@ -5,7 +5,6 @@ import logging
import pytest # type: ignore import pytest # type: ignore
from conftest import TrackedContainer from conftest import TrackedContainer
from package_helper import CondaPackageHelper from package_helper import CondaPackageHelper
LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__)

View File

@@ -2,8 +2,8 @@
# Distributed under the terms of the Modified BSD License. # Distributed under the terms of the Modified BSD License.
import logging import logging
import pytest # type: ignore
import pytest # type: ignore
from conftest import TrackedContainer from conftest import TrackedContainer
LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__)

View File

@@ -35,11 +35,10 @@ Example:
""" """
import logging import logging
from typing import Callable, Iterable
import pytest # type: ignore import pytest # type: ignore
from conftest import TrackedContainer from conftest import TrackedContainer
from typing import Callable, Iterable
from package_helper import CondaPackageHelper from package_helper import CondaPackageHelper
LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__)

View File

@@ -2,9 +2,8 @@
# Distributed under the terms of the Modified BSD License. # Distributed under the terms of the Modified BSD License.
import logging import logging
from packaging import version # type: ignore
from conftest import TrackedContainer from conftest import TrackedContainer
from packaging import version # type: ignore
LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__)

View File

@@ -2,11 +2,11 @@
# Distributed under the terms of the Modified BSD License. # Distributed under the terms of the Modified BSD License.
import logging import logging
import time
from typing import Optional from typing import Optional
import pytest # type: ignore import pytest # type: ignore
import requests import requests
import time
from conftest import TrackedContainer, find_free_port from conftest import TrackedContainer, find_free_port
LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__)

View File

@@ -1,19 +1,17 @@
# Copyright (c) Jupyter Development Team. # Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License. # Distributed under the terms of the Modified BSD License.
from contextlib import closing
import os
import logging import logging
import os
import socket import socket
from contextlib import closing
from typing import Any, Optional from typing import Any, Optional
import docker import docker
from docker.models.containers import Container
import pytest # type: ignore import pytest # type: ignore
import requests import requests
from docker.models.containers import Container
from urllib3.util.retry import Retry
from requests.adapters import HTTPAdapter from requests.adapters import HTTPAdapter
from urllib3.util.retry import Retry
LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__)

View File

@@ -27,7 +27,7 @@
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"from sympy import init_printing, symbols, sin, diff, integrate" "from sympy import diff, init_printing, integrate, sin, symbols"
] ]
}, },
{ {

View File

@@ -2,10 +2,9 @@
# Distributed under the terms of the Modified BSD License. # Distributed under the terms of the Modified BSD License.
import logging import logging
import pytest # type: ignore
from pathlib import Path from pathlib import Path
import pytest # type: ignore
from conftest import TrackedContainer from conftest import TrackedContainer
LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__)

View File

@@ -22,17 +22,16 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE. # SOFTWARE.
import json
import logging
import re import re
from collections import defaultdict from collections import defaultdict
from itertools import chain from itertools import chain
import logging
import json
from typing import Any, Optional from typing import Any, Optional
from docker.models.containers import Container
from tabulate import tabulate
from conftest import TrackedContainer from conftest import TrackedContainer
from docker.models.containers import Container
from tabulate import tabulate
LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__)

View File

@@ -4,7 +4,6 @@ import logging
from conftest import TrackedContainer from conftest import TrackedContainer
LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__)

View File

@@ -5,10 +5,8 @@ import argparse
import logging import logging
import plumbum import plumbum
from plumbum.cmd import pytest
from images_hierarchy import get_test_dirs from images_hierarchy import get_test_dirs
from plumbum.cmd import pytest
LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__)

View File

@@ -1,4 +1,4 @@
from setuptools import setup
from Cython.Build import cythonize from Cython.Build import cythonize
from setuptools import setup
setup(ext_modules=cythonize("helloworld.pyx")) setup(ext_modules=cythonize("helloworld.pyx"))

View File

@@ -1,11 +1,12 @@
# Matplotlit: Create a simple plot example. # Matplotlit: Create a simple plot example.
# Refs: https://matplotlib.org/3.1.1/gallery/lines_bars_and_markers/simple_plot.html # Refs: https://matplotlib.org/3.1.1/gallery/lines_bars_and_markers/simple_plot.html
import os
# Optional test with [Matplotlib Jupyter Integration](https://github.com/matplotlib/ipympl) # Optional test with [Matplotlib Jupyter Integration](https://github.com/matplotlib/ipympl)
# %matplotlib widget # %matplotlib widget
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import numpy as np import numpy as np
import os
# Data for plotting # Data for plotting
t = np.arange(0.0, 2.0, 0.01) t = np.arange(0.0, 2.0, 0.01)

View File

@@ -1,7 +1,8 @@
# Matplotlit: Test tex fonts # Matplotlit: Test tex fonts
import os
import matplotlib import matplotlib
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import os
matplotlib.rcParams["pgf.texsystem"] = "pdflatex" matplotlib.rcParams["pgf.texsystem"] = "pdflatex"
matplotlib.rcParams.update( matplotlib.rcParams.update(

View File

@@ -3,7 +3,6 @@
import logging import logging
import pytest # type: ignore import pytest # type: ignore
from conftest import TrackedContainer from conftest import TrackedContainer
LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__)

View File

@@ -2,10 +2,9 @@
# Distributed under the terms of the Modified BSD License. # Distributed under the terms of the Modified BSD License.
import logging import logging
import pytest # type: ignore
from pathlib import Path from pathlib import Path
import pytest # type: ignore
from conftest import TrackedContainer from conftest import TrackedContainer
LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__)

View File

@@ -4,6 +4,5 @@
import numpy as np import numpy as np
import pandas as pd import pandas as pd
np.random.seed(0) np.random.seed(0)
print(pd.Series(np.random.randint(0, 7, size=10)).sum()) print(pd.Series(np.random.randint(0, 7, size=10)).sum())

View File

@@ -2,6 +2,5 @@
# Distributed under the terms of the Modified BSD License. # Distributed under the terms of the Modified BSD License.
import tensorflow as tf import tensorflow as tf
print(tf.constant("Hello, TensorFlow")) print(tf.constant("Hello, TensorFlow"))
print(tf.reduce_sum(tf.random.normal([1000, 1000]))) print(tf.reduce_sum(tf.random.normal([1000, 1000])))