Skip to content

Commit

Permalink
using black isort and ruff in the test CI pipeline (#63)
Browse files Browse the repository at this point in the history
* using black isort and ruff in the test CI pipeline

* removed duplicate installation

* testing with black and isort marketplace options

* testing black action

* testing with ruff

* fixed black .

* updated black and ruff version and run black again

* fixed as per isort

* added profile black to isort in CI

* testing if ruff gives error in CI

* fixed black but keeping error as per ruff

* fixed as per ruff
  • Loading branch information
krishnaglodha authored Sep 4, 2024
1 parent e11eff7 commit 1d3f60e
Show file tree
Hide file tree
Showing 24 changed files with 424 additions and 334 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,16 @@ jobs:
run: poetry install
- name: Run tests
run: poetry run pytest

- name: Run black
uses: psf/black@stable

- name: Run isort
uses: isort/isort-action@v1
with :
configuration : "--profile black"

- name : Ruff Check
uses: jpetrucciani/ruff-check@main
with:
black_args: "."
flags: '--fix'
207 changes: 111 additions & 96 deletions poetry.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ mkdocs-material = "^9.0.14"
pytest = "^7.1.2"
respx = "^0.20.1"
mypy = "^0.960"
ruff = "^0.6.1"
black = "^22.3.0"
ruff = "^0.6.3"
black = "^24.8.0"
isort = "^5.10.1"
pytest-asyncio = "^0.21.0"
anyio = {extras = ["trio"], version = "^3.3.4"}
Expand Down
3 changes: 1 addition & 2 deletions src/geoserverx/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from . import _sync, _async, utils, models

from . import _async, _sync, models, utils

__version__ = "0.1.0"
__author__ = "krishnaglodha <krishnaglodha@gmail.com>"
Expand Down
46 changes: 24 additions & 22 deletions src/geoserverx/_async/gsx.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
from dataclasses import dataclass
from typing import Union, Optional
from geoserverx.utils.logger import std_out_logger
from geoserverx.utils.enums import GSResponseEnum
from typing import Optional, Union

from geoserverx.models.coverages_store import CoveragesStoreModel, CoveragesStoresModel
from geoserverx.models.data_store import (
CreateDataStoreModel,
CreateStoreItem,
DataStoreModel,
DataStoresModel,
MainCreateDataStoreModel,
)
from geoserverx.models.gs_response import GSResponse
from geoserverx.utils.errors import GeoServerXError
from geoserverx.models.style import StyleModel, AllStylesModel
from geoserverx.utils.http_client import AsyncClient
from geoserverx.utils.auth import GeoServerXAuth
from geoserverx.models.layer_group import LayerGroupsModel
from geoserverx.models.layers import LayerModel, LayersModel
from geoserverx.models.style import AllStylesModel, StyleModel
from geoserverx.models.workspace import (
NewWorkspace,
NewWorkspaceInfo,
WorkspaceModel,
WorkspacesModel,
)
from geoserverx.models.data_store import (
DataStoreModel,
DataStoresModel,
CreateDataStoreModel,
CreateStoreItem,
MainCreateDataStoreModel,
)
from geoserverx.models.layer_group import LayerGroupsModel
from geoserverx.models.layers import LayersModel, LayerModel
from geoserverx.models.coverages_store import CoveragesStoreModel, CoveragesStoresModel
from geoserverx.utils.auth import GeoServerXAuth
from geoserverx.utils.enums import GSResponseEnum
from geoserverx.utils.errors import GeoServerXError
from geoserverx.utils.http_client import AsyncClient
from geoserverx.utils.logger import std_out_logger
from geoserverx.utils.services.async_datastore import (
AddDataStoreProtocol,
CreateFileStore,
ShapefileStore,
GPKGfileStore,
ShapefileStore,
)


Expand Down Expand Up @@ -294,16 +295,17 @@ async def delete_layer(self, workspace: str, layer: str) -> GSResponse:
results = self.response_recognise(responses.status_code)
return results


# Get all layer groups
async def get_all_layer_groups(self,workspace: Optional[str] = None) -> Union[LayerGroupsModel, GSResponse]:
async def get_all_layer_groups(
self, workspace: Optional[str] = None
) -> Union[LayerGroupsModel, GSResponse]:
Client = self.http_client
if workspace:
responses = await Client.get(f"workspaces/{workspace}/layergroups")
else :
else:
responses = await Client.get("layergroups")
if responses.status_code == 200:
return LayerGroupsModel.model_validate(responses.json())
else:
results = self.response_recognise(responses.status_code)
return results
return results
51 changes: 26 additions & 25 deletions src/geoserverx/_sync/gsx.py
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
from dataclasses import dataclass
from typing import Union, Optional
from geoserverx.utils.logger import std_out_logger
from typing import Optional, Union

from geoserverx.utils.errors import GeoServerXError
from geoserverx.utils.enums import GSResponseEnum
import httpx
from pydantic import ValidationError

from geoserverx.models.style import StyleModel, AllStylesModel
from geoserverx.models.workspace import (
NewWorkspace,
NewWorkspaceInfo,
WorkspaceModel,
WorkspacesModel,
)
from geoserverx.models.coverages_layer import CoverageModel
from geoserverx.models.coverages_store import CoveragesStoreModel, CoveragesStoresModel
from geoserverx.models.data_store import (
DataStoreModel,
DataStoresModel,
CreateDataStoreModel,
CreateStoreItem,
DataStoreModel,
DataStoresModel,
MainCreateDataStoreModel,
)
from geoserverx.models.featuretypes_layer import FeatureTypesModel
from geoserverx.models.layers import LayersModel, LayerModel
from geoserverx.models.coverages_store import CoveragesStoreModel, CoveragesStoresModel
from geoserverx.models.layer_group import LayerGroupsModel
from geoserverx.models.coverages_layer import CoverageModel
from geoserverx.models.gs_response import GSResponse
from geoserverx.models.layer_group import LayerGroupsModel
from geoserverx.models.layers import LayerModel, LayersModel
from geoserverx.models.style import AllStylesModel, StyleModel
from geoserverx.models.workspace import (
NewWorkspace,
NewWorkspaceInfo,
WorkspaceModel,
WorkspacesModel,
)
from geoserverx.utils.auth import GeoServerXAuth
from geoserverx.utils.enums import GSResponseEnum
from geoserverx.utils.errors import GeoServerXError
from geoserverx.utils.http_client import SyncClient
from geoserverx.utils.logger import std_out_logger
from geoserverx.utils.services.datastore import (
AddDataStoreProtocol,
CreateFileStore,
ShapefileStore,
GPKGfileStore,
ShapefileStore,
)
from geoserverx.utils.http_client import SyncClient
from geoserverx.utils.auth import GeoServerXAuth
import httpx
from pydantic import ValidationError


@dataclass
Expand Down Expand Up @@ -418,14 +418,15 @@ def delete_layer(self, workspace: str, layer: str) -> GSResponse:
results = self.response_recognise(responses.status_code)
return results


# Get all layer groups
@exception_handler
def get_all_layer_groups(self,workspace: Optional[str] = None) -> Union[LayerGroupsModel, GSResponse]:
def get_all_layer_groups(
self, workspace: Optional[str] = None
) -> Union[LayerGroupsModel, GSResponse]:
Client = self.http_client
if workspace:
responses = Client.get(f"workspaces/{workspace}/layergroups")
else :
else:
responses = Client.get("layergroups")
if responses.status_code == 200:
return LayerGroupsModel.model_validate(responses.json())
Expand Down
14 changes: 8 additions & 6 deletions src/geoserverx/cli/cli.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import typer
from enum import Enum
from geoserverx._sync.gsx import SyncGeoServerX
from rich import print
import json
from enum import Enum
from pathlib import Path

import typer
from rich import print

from geoserverx._sync.gsx import SyncGeoServerX

app = typer.Typer()


Expand Down Expand Up @@ -373,7 +375,7 @@ def layer(
request: requestEnum = requestEnum._sync,
workspace: str = typer.Option(..., help="Workspace name"),
layer: str = typer.Option(..., help="Layer name"),
detail:bool = typer.Option(False, help="Detail Info"),
detail: bool = typer.Option(False, help="Detail Info"),
url: str = typer.Option(
"http://127.0.0.1:8080/geoserver/rest/", help="Geoserver REST URL"
),
Expand All @@ -399,7 +401,7 @@ def layer(
@app.command(help="Get layer groups in the Geoserver")
def layer_groups(
request: requestEnum = requestEnum._sync,
workspace: str = typer.Option( default=None,help="Workspace name"),
workspace: str = typer.Option(default=None, help="Workspace name"),
url: str = typer.Option(
"http://127.0.0.1:8080/geoserver/rest/", help="Geoserver REST URL"
),
Expand Down
Loading

0 comments on commit 1d3f60e

Please sign in to comment.