Skip to content

Commit

Permalink
fix: update pre-commit config so that isort works (#267)
Browse files Browse the repository at this point in the history
  • Loading branch information
CBROWN-ONS authored May 9, 2024
1 parent 315aa38 commit cbdf383
Show file tree
Hide file tree
Showing 55 changed files with 306 additions and 313 deletions.
18 changes: 9 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ repos:
- --extra-keys
- "metadata.colab metadata.kernelspec cell.metadata.colab cell.metadata.executionInfo cell.metadata.id cell.metadata.outputId"

# ----- isort - imports sorting
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
name: isort (python)
types: [python]
args: [ "--profile", "black", "--filter-files" ]

# ----- black - code formatting
- repo: https://github.com/psf/black
rev: 22.3.0 # Replace by any tag/version: https://github.com/psf/black/tags
Expand All @@ -49,15 +58,6 @@ repos:
- id: flake8
name: flake8 - Python linting

# ----- isort - imports sorting
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
name: isort - Sort Python imports (auto-fixes)
types: [ cython, pyi, python ]
args: [ "--profile", "black", "--filter-files" ]

# ----- nbQA - notebook quality assuring
- repo: https://github.com/nbQA-dev/nbQA
rev: 0.12.0
Expand Down
24 changes: 11 additions & 13 deletions notebooks/e2e/e2e_leeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,27 @@
Call in script wide imports and the configuration information.
"""

# %%
import toml
import os
import datetime
import os

import folium
import geopandas as gpd
import pandas as pd
import gtfs_kit as gk
import folium
import pandas as pd
import seaborn as sns

# %%
import toml
from folium.map import Icon
from pyprojroot import here
from r5py import TransportMode, TransportNetwork, TravelTimeMatrixComputer
from shapely.geometry import box
from folium.map import Icon
from r5py import (
TransportNetwork,
TravelTimeMatrixComputer,
TransportMode,
)
from transport_performance.urban_centres.raster_uc import UrbanCentre
from transport_performance.population.rasterpop import RasterPop

from transport_performance.gtfs.gtfs_utils import bbox_filter_gtfs
from transport_performance.gtfs.validation import GtfsInstance
from transport_performance.osm.osm_utils import filter_osm
from transport_performance.population.rasterpop import RasterPop
from transport_performance.urban_centres.raster_uc import UrbanCentre
from transport_performance.utils.raster import (
merge_raster_files,
sum_resample_file,
Expand Down
22 changes: 11 additions & 11 deletions notebooks/e2e/e2e_london.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
Call in script wide imports and the configuration information.
"""

# %%
import toml
import os

# import datetime
Expand All @@ -20,27 +18,29 @@
# import pandas as pd
import gtfs_kit as gk

# import folium

# %%
import toml
from pyprojroot import here
from shapely.geometry import box

from transport_performance.gtfs.gtfs_utils import bbox_filter_gtfs
from transport_performance.gtfs.validation import GtfsInstance
from transport_performance.osm.osm_utils import filter_osm
from transport_performance.population.rasterpop import RasterPop

# from folium.map import Icon
# from r5py import (
# TransportNetwork,
# TravelTimeMatrixComputer,
# TransportMode,
# )
from transport_performance.urban_centres.raster_uc import UrbanCentre
from transport_performance.population.rasterpop import RasterPop
from transport_performance.gtfs.gtfs_utils import bbox_filter_gtfs
from transport_performance.gtfs.validation import GtfsInstance
from transport_performance.osm.osm_utils import filter_osm

from transport_performance.utils.raster import (
merge_raster_files,
# sum_resample_file,
)
) # sum_resample_file,

# import folium


# %%
# config filepath, and loading
Expand Down
24 changes: 11 additions & 13 deletions notebooks/e2e/e2e_marseille.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,28 @@
Call in script wide imports and the configuration information.
"""

# %%
import toml
import datetime
import glob
import os
import datetime

import folium
import geopandas as gpd
import pandas as pd
import gtfs_kit as gk
import folium
import pandas as pd
import seaborn as sns

# %%
import toml
from folium.map import Icon
from pyprojroot import here
from r5py import TransportMode, TransportNetwork, TravelTimeMatrixComputer
from shapely.geometry import box
from folium.map import Icon
from r5py import (
TransportNetwork,
TravelTimeMatrixComputer,
TransportMode,
)
from transport_performance.urban_centres.raster_uc import UrbanCentre
from transport_performance.population.rasterpop import RasterPop

from transport_performance.gtfs.gtfs_utils import bbox_filter_gtfs
from transport_performance.gtfs.validation import GtfsInstance
from transport_performance.osm.osm_utils import filter_osm
from transport_performance.population.rasterpop import RasterPop
from transport_performance.urban_centres.raster_uc import UrbanCentre
from transport_performance.utils.raster import (
merge_raster_files,
sum_resample_file,
Expand Down
24 changes: 11 additions & 13 deletions notebooks/e2e/e2e_newport.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,27 @@
Call in script wide imports and the configuration information.
"""

# %%
import toml
import os
import datetime
import os

import folium
import geopandas as gpd
import pandas as pd
import gtfs_kit as gk
import folium
import pandas as pd
import seaborn as sns

# %%
import toml
from folium.map import Icon
from pyprojroot import here
from r5py import TransportMode, TransportNetwork, TravelTimeMatrixComputer
from shapely.geometry import box
from folium.map import Icon
from r5py import (
TransportNetwork,
TravelTimeMatrixComputer,
TransportMode,
)
from transport_performance.urban_centres.raster_uc import UrbanCentre
from transport_performance.population.rasterpop import RasterPop

from transport_performance.gtfs.gtfs_utils import bbox_filter_gtfs
from transport_performance.gtfs.validation import GtfsInstance
from transport_performance.osm.osm_utils import filter_osm
from transport_performance.population.rasterpop import RasterPop
from transport_performance.urban_centres.raster_uc import UrbanCentre
from transport_performance.utils.raster import (
merge_raster_files,
sum_resample_file,
Expand Down
4 changes: 2 additions & 2 deletions notebooks/gtfs/check_unmatched_id_warnings.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
# %%
# imports
import gtfs_kit as gk
from pyprojroot import here
import pandas as pd
import numpy as np
import pandas as pd
from pyprojroot import here

# %%
# initialise my feed from GTFS test data
Expand Down
2 changes: 1 addition & 1 deletion notebooks/gtfs/stop_id_check.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""A notebook containing viable code for additional stop_id validation."""
# %%
# IMPORTS
from transport_performance.gtfs.validation import GtfsInstance
from transport_performance.gtfs.gtfs_utils import _add_validation_row
from transport_performance.gtfs.validation import GtfsInstance


# %%
Expand Down
14 changes: 6 additions & 8 deletions notebooks/metrics/metrics_experiments.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,21 @@
Call in script wide imports and the configuration information.
"""

# %%
import folium
import geopandas as gpd
import os
import pandas as pd
import pathlib
import pickle
from typing import Union

# %%
import folium
import geopandas as gpd
import pandas as pd
from folium.map import Icon
from haversine import haversine_vector
from pyprojroot import here
from tqdm import tqdm
from typing import Union

from transport_performance.utils.defence import (
_check_parent_dir_exists,
)
from transport_performance.utils.defence import _check_parent_dir_exists

# %%
# name of area and source of metrics inputs
Expand Down
1 change: 1 addition & 0 deletions notebooks/osm/01-visualise-osm.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Visualise OMS spatial features."""
# %%
from pyprojroot import here

from transport_performance.osm import validate_osm as osmval

# %%
Expand Down
35 changes: 18 additions & 17 deletions notebooks/population/grid_pop_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,34 +49,35 @@
"""

# %%
import rasterio as rio
import logging
import os
import sys
import logging
import numpy as np
import pandas as pd
import geopandas as gpd
import matplotlib.pyplot as plt
import seaborn as sns
import textwrap
from datetime import datetime

import cartopy.crs as ccrs
import cartopy.io.img_tiles as cimgt
import geopandas as gpd
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd

# %%
import rasterio as rio
import requests
import rioxarray
import seaborn as sns
import xarray as xr
import requests
import textwrap

from datetime import datetime
from pyproj import Transformer
from pyprojroot import here
from geocube.vector import vectorize
from matplotlib import colormaps
from matplotlib.colors import LogNorm
from matplotlib.ticker import AutoMinorLocator
from pyproj import Transformer
from pyprojroot import here
from rasterio.warp import Resampling
from geocube.vector import vectorize
from rioxarray.merge import merge_arrays
from rioxarray.exceptions import NoDataInBounds
from requests.exceptions import HTTPError
from rioxarray.exceptions import NoDataInBounds
from rioxarray.merge import merge_arrays
from shapely.geometry.polygon import Polygon
from xarray import DataArray

Expand Down
8 changes: 4 additions & 4 deletions notebooks/urban_centres/poc_urban_centres.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
# %%
import os

import folium
import geopandas as gpd
from shapely.geometry import box
from pyprojroot import here
import matplotlib.pyplot as plt
import rioxarray as rxr
from pyprojroot import here
from rioxarray.merge import merge_arrays
import matplotlib.pyplot as plt
import folium
from shapely.geometry import box

import transport_performance.urban_centres.raster_uc as ucc

Expand Down
5 changes: 3 additions & 2 deletions pipeline/gtfs/01-validate-gtfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
8. new - modalities available (including extended spec)
9. new - feed stats by is-weekend
"""
import subprocess
import time

import toml
from pyprojroot import here
import time
import subprocess

from transport_performance.gtfs.validation import GtfsInstance
from transport_performance.utils.defence import _is_expected_filetype
Expand Down
6 changes: 4 additions & 2 deletions pipeline/osm/01-validate-osm.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
4. Inspect tags by feature type.
"""

import time

import toml
from pyprojroot import here

from transport_performance.osm.validate_osm import (
FindIds,
FindTags,
FindLocations,
FindTags,
)
import time

CONFIG = toml.load(here("pipeline/osm/config/01-validate-osm.toml"))
OSM_PTH = CONFIG["OSM"]["PATH"]
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ exclude_lines = [
# `isort` configurations
[tool.isort]
profile = "black"
skip_glob = ["notebooks/*"]
line_length = 79

# `pytest` configurations
[tool.pytest.ini_options]
Expand Down
6 changes: 3 additions & 3 deletions scripts/prep-fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
station, filtered to a date of 20230613.
"""
import os
import gtfs_kit as gk

import geopandas as gpd
from shapely.geometry import box
import gtfs_kit as gk
from pyprojroot import here
from shapely.geometry import box

from transport_performance.osm.osm_utils import filter_osm


fix_dat = os.path.join("tests", "data", "gtfs")
gtfs_zip = [
os.path.join(fix_dat, x) for x in os.listdir(fix_dat) if x.endswith(".zip")
Expand Down
Loading

0 comments on commit cbdf383

Please sign in to comment.