From 09df1580bc3ab576f07290e8fcf361a1eadf833c Mon Sep 17 00:00:00 2001 From: airwish Date: Tue, 3 Sep 2024 17:49:28 +0800 Subject: [PATCH] fix: Migrate command-line tool config to pyproject.toml (#3205) * chore: Migrate command-line config to pyproject.toml * fix: Correct files according to the config * fix: Correct comment length --- streampipes-client-python/.pre-commit-config.yaml | 10 +++++----- streampipes-client-python/pyproject.toml | 10 ++++++++++ .../streampipes/endpoint/api/data_lake_measure.py | 6 ++++-- .../functions/utils/data_stream_generator.py | 3 ++- streampipes-client-python/streampipes/model/common.py | 2 +- .../streampipes/model/resource/data_stream.py | 2 +- 6 files changed, 23 insertions(+), 10 deletions(-) diff --git a/streampipes-client-python/.pre-commit-config.yaml b/streampipes-client-python/.pre-commit-config.yaml index 38b2663762..04ccf3070c 100644 --- a/streampipes-client-python/.pre-commit-config.yaml +++ b/streampipes-client-python/.pre-commit-config.yaml @@ -47,35 +47,35 @@ repos: name: pyupgrade language: python types: [ python ] - entry: pyupgrade --py38 --keep-runtime-typing + entry: pyupgrade --py38-plus --keep-runtime-typing verbose: true - id: autoflake name: autoflake language: python types: [ python ] - entry: autoflake --remove-all-unused-imports --expand-star-imports --in-place --remove-unused-variables --remove-duplicate-keys + entry: autoflake verbose: true - id: isort name: isort language: python types: [ python ] - entry: isort --profile black + entry: isort verbose: true - id: black name: black language: python types: [ python ] - entry: black --line-length=120 + entry: black verbose: true - id: blacken-docks name: blacken-docs language: python types: [ python ] - entry: black --line-length=120 + entry: black verbose: true - id: mypy diff --git a/streampipes-client-python/pyproject.toml b/streampipes-client-python/pyproject.toml index 0612a9afb3..108fd4daa4 100644 --- a/streampipes-client-python/pyproject.toml +++ b/streampipes-client-python/pyproject.toml @@ -112,6 +112,16 @@ twine = "5.1.0" name = "PyPI" priority = "primary" +[tool.autoflake] +remove-all-unused-imports = true +expand-star-imports = true +in-place = true +remove-unused-variables = true +remove-duplicate-keys = true + +[tool.black] +line-length = 120 + [tool.interrogate] ignore-init-method = true ignore-magic = true diff --git a/streampipes-client-python/streampipes/endpoint/api/data_lake_measure.py b/streampipes-client-python/streampipes/endpoint/api/data_lake_measure.py index ebb2584651..1ef107b1e7 100644 --- a/streampipes-client-python/streampipes/endpoint/api/data_lake_measure.py +++ b/streampipes-client-python/streampipes/endpoint/api/data_lake_measure.py @@ -55,7 +55,8 @@ class MeasurementGetQueryConfig(BaseModel): If provided, the returned data only consists of the given columns.
Please be aware that the column `time` as an index is always included. end_date: Optional[datetime] - Limits the queried data to only include data that is older than the specified time. In other words, any data that occurred after the end_date will not be included in the query results. + Limits the queried data to only include data that is older than the specified time. + In other words, any data that occurred after the end_date will not be included in the query results. limit: Optional[int] Amount of records returned at maximum (default: `1000`)
This needs to be at least `1` @@ -69,7 +70,8 @@ class MeasurementGetQueryConfig(BaseModel): Page number used for paging operation
This needs to be at least `1` start_date: Optional[datetime] - Limits the queried data to only include data that is newer than the specified time. In other words, any data that occurred before the start_date will not be included in the query results. + Limits the queried data to only include data that is newer than the specified time. + In other words, any data that occurred before the start_date will not be included in the query results. """ _regex_comma_separated_string = r"^[0-9a-zA-Z\_]+(,[0-9a-zA-Z\_]+)*$" diff --git a/streampipes-client-python/streampipes/functions/utils/data_stream_generator.py b/streampipes-client-python/streampipes/functions/utils/data_stream_generator.py index e537e4f2d8..6d042088f3 100644 --- a/streampipes-client-python/streampipes/functions/utils/data_stream_generator.py +++ b/streampipes-client-python/streampipes/functions/utils/data_stream_generator.py @@ -106,7 +106,8 @@ def create_data_stream( sanitized_stream_id = stream_id.replace(" ", "") # Assign a default topic name incorporating the unique stream ID to each protocol. - # This ensures the topic name remains consistent across function restarts, avoiding reliance on client-side defaults. + # This ensures the topic name remains consistent across function restarts, + # avoiding reliance on client-side defaults. for protocol in transport_protocols: protocol.topic_definition.actual_topic_name = f"org.apache.streampipes.connect.{sanitized_stream_id}" diff --git a/streampipes-client-python/streampipes/model/common.py b/streampipes-client-python/streampipes/model/common.py index 489af5222c..950bb7f066 100644 --- a/streampipes-client-python/streampipes/model/common.py +++ b/streampipes-client-python/streampipes/model/common.py @@ -24,7 +24,7 @@ from typing import List, Optional from uuid import uuid4 -from pydantic.v1 import BaseModel, Field, StrictBool, StrictInt, StrictStr +from pydantic.v1 import BaseModel, Field, StrictInt, StrictStr __all__ = [ "BaseElement", diff --git a/streampipes-client-python/streampipes/model/resource/data_stream.py b/streampipes-client-python/streampipes/model/resource/data_stream.py index e60358e26b..a44f9548f9 100644 --- a/streampipes-client-python/streampipes/model/resource/data_stream.py +++ b/streampipes-client-python/streampipes/model/resource/data_stream.py @@ -16,7 +16,7 @@ # from typing import List, Optional -from pydantic.v1 import Field, StrictBool, StrictInt, StrictStr +from pydantic.v1 import Field, StrictBool, StrictStr from streampipes.model.common import ( ApplicationLink,