From feb9b2dc9faa3b3aabaccd4c365be34ea7822c20 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Mon, 2 Jan 2023 18:14:39 +0100 Subject: [PATCH] [influxdb-client] Annotate Point and partially client classes (#9442) --- .../influxdb_client/client/_base.pyi | 40 +++++++++++++------ .../client/influxdb_client.pyi | 30 ++++++++++---- .../client/influxdb_client_async.pyi | 25 +++++++++--- .../influxdb_client/client/write/point.pyi | 40 ++++++++++++++----- 4 files changed, 98 insertions(+), 37 deletions(-) diff --git a/stubs/influxdb-client/influxdb_client/client/_base.pyi b/stubs/influxdb-client/influxdb_client/client/_base.pyi index af4c3fddc..20d5f7e4d 100644 --- a/stubs/influxdb-client/influxdb_client/client/_base.pyi +++ b/stubs/influxdb-client/influxdb_client/client/_base.pyi @@ -5,26 +5,40 @@ from influxdb_client import Configuration LOGGERS_NAMES: Incomplete class _BaseClient: - url: Incomplete - token: Incomplete - org: Incomplete - default_tags: Incomplete - conf: Incomplete - auth_header_name: Incomplete - auth_header_value: Incomplete - retries: Incomplete - profilers: Incomplete + url: str + token: str | None + org: str | None + default_tags: Incomplete | None + conf: _Configuration + auth_header_name: Incomplete | None + auth_header_value: Incomplete | None + retries: bool | Incomplete + profilers: Incomplete | None def __init__( self, - url, - token, - debug: Incomplete | None = ..., + url: str, + token: str | None, + debug: bool | None = ..., timeout: int = ..., enable_gzip: bool = ..., org: str | None = ..., default_tags: dict[Incomplete, Incomplete] | None = ..., http_client_logger: str | None = ..., - **kwargs, + *, + verify_ssl: bool = ..., + ssl_ca_cert: Incomplete | None = ..., + cert_file: Incomplete | None = ..., + cert_key_file: Incomplete | None = ..., + cert_key_password: Incomplete | None = ..., + ssl_context: Incomplete | None = ..., + proxy: Incomplete | None = ..., + proxy_headers: Incomplete | None = ..., + connection_pool_maxsize: int = ..., + username: Incomplete | None = ..., + password: Incomplete | None = ..., + auth_basic: bool = ..., + retries: bool | Incomplete = ..., + profilers: Incomplete | None = ..., ) -> None: ... class _BaseQueryApi: diff --git a/stubs/influxdb-client/influxdb_client/client/influxdb_client.pyi b/stubs/influxdb-client/influxdb_client/client/influxdb_client.pyi index 7c627d05e..6cc070cd5 100644 --- a/stubs/influxdb-client/influxdb_client/client/influxdb_client.pyi +++ b/stubs/influxdb-client/influxdb_client/client/influxdb_client.pyi @@ -1,4 +1,4 @@ -from _typeshed import Incomplete +from _typeshed import Incomplete, Self from influxdb_client import HealthCheck, InvokableScriptsApi, Ready from influxdb_client.client._base import _BaseClient @@ -10,7 +10,7 @@ from influxdb_client.client.organizations_api import OrganizationsApi from influxdb_client.client.query_api import QueryApi, QueryOptions from influxdb_client.client.tasks_api import TasksApi from influxdb_client.client.users_api import UsersApi -from influxdb_client.client.write_api import WriteApi +from influxdb_client.client.write_api import PointSettings, WriteApi, WriteOptions logger: Incomplete @@ -18,22 +18,36 @@ class InfluxDBClient(_BaseClient): api_client: Incomplete def __init__( self, - url, + url: str, token: str | None = ..., - debug: Incomplete | None = ..., + debug: bool | None = ..., timeout: int = ..., enable_gzip: bool = ..., org: str | None = ..., default_tags: dict[Incomplete, Incomplete] | None = ..., - **kwargs, + *, + verify_ssl: bool = ..., + ssl_ca_cert: Incomplete | None = ..., + cert_file: Incomplete | None = ..., + cert_key_file: Incomplete | None = ..., + cert_key_password: Incomplete | None = ..., + ssl_context: Incomplete | None = ..., + proxy: Incomplete | None = ..., + proxy_headers: Incomplete | None = ..., + connection_pool_maxsize: int = ..., + username: Incomplete | None = ..., + password: Incomplete | None = ..., + auth_basic: bool = ..., + retries: bool | Incomplete = ..., + profilers: Incomplete | None = ..., ) -> None: ... - def __enter__(self): ... - def __exit__(self, exc_type, exc_value, traceback) -> None: ... + def __enter__(self: Self) -> Self: ... + def __exit__(self, exc_type: object, exc_value: object, traceback: object) -> None: ... @classmethod def from_config_file(cls, config_file: str = ..., debug: Incomplete | None = ..., enable_gzip: bool = ..., **kwargs): ... @classmethod def from_env_properties(cls, debug: Incomplete | None = ..., enable_gzip: bool = ..., **kwargs): ... - def write_api(self, write_options=..., point_settings=..., **kwargs) -> WriteApi: ... + def write_api(self, write_options: WriteOptions = ..., point_settings: PointSettings = ..., **kwargs) -> WriteApi: ... def query_api(self, query_options: QueryOptions = ...) -> QueryApi: ... def invokable_scripts_api(self) -> InvokableScriptsApi: ... def close(self) -> None: ... diff --git a/stubs/influxdb-client/influxdb_client/client/influxdb_client_async.pyi b/stubs/influxdb-client/influxdb_client/client/influxdb_client_async.pyi index 3338cdf53..14605d16d 100644 --- a/stubs/influxdb-client/influxdb_client/client/influxdb_client_async.pyi +++ b/stubs/influxdb-client/influxdb_client/client/influxdb_client_async.pyi @@ -4,6 +4,7 @@ from influxdb_client.client._base import _BaseClient from influxdb_client.client.delete_api_async import DeleteApiAsync from influxdb_client.client.query_api import QueryOptions from influxdb_client.client.query_api_async import QueryApiAsync +from influxdb_client.client.write_api import PointSettings from influxdb_client.client.write_api_async import WriteApiAsync logger: Incomplete @@ -12,16 +13,30 @@ class InfluxDBClientAsync(_BaseClient): api_client: Incomplete def __init__( self, - url, + url: str, token: str | None = ..., org: str | None = ..., - debug: Incomplete | None = ..., + debug: bool | None = ..., timeout: int = ..., enable_gzip: bool = ..., - **kwargs, + *, + verify_ssl: bool = ..., + ssl_ca_cert: Incomplete | None = ..., + cert_file: Incomplete | None = ..., + cert_key_file: Incomplete | None = ..., + cert_key_password: Incomplete | None = ..., + ssl_context: Incomplete | None = ..., + proxy: Incomplete | None = ..., + proxy_headers: Incomplete | None = ..., + connection_pool_maxsize: int = ..., + username: Incomplete | None = ..., + password: Incomplete | None = ..., + auth_basic: bool = ..., + retries: bool | Incomplete = ..., + profilers: Incomplete | None = ..., ) -> None: ... async def __aenter__(self: Self) -> Self: ... - async def __aexit__(self, exc_type, exc, tb) -> None: ... + async def __aexit__(self, exc_type: object, exc: object, tb: object) -> None: ... async def close(self) -> None: ... @classmethod def from_config_file(cls, config_file: str = ..., debug: Incomplete | None = ..., enable_gzip: bool = ..., **kwargs): ... @@ -31,5 +46,5 @@ class InfluxDBClientAsync(_BaseClient): async def version(self) -> str: ... async def build(self) -> str: ... def query_api(self, query_options: QueryOptions = ...) -> QueryApiAsync: ... - def write_api(self, point_settings=...) -> WriteApiAsync: ... + def write_api(self, point_settings: PointSettings = ...) -> WriteApiAsync: ... def delete_api(self) -> DeleteApiAsync: ... diff --git a/stubs/influxdb-client/influxdb_client/client/write/point.pyi b/stubs/influxdb-client/influxdb_client/client/write/point.pyi index 26fe6e744..a3aadf750 100644 --- a/stubs/influxdb-client/influxdb_client/client/write/point.pyi +++ b/stubs/influxdb-client/influxdb_client/client/write/point.pyi @@ -1,21 +1,39 @@ -from _typeshed import Incomplete +from _typeshed import Incomplete, Self, SupportsGetItem, SupportsItems +from collections.abc import Iterable +from datetime import datetime, timedelta +from numbers import Integral +from typing import Any +from typing_extensions import Literal, TypeAlias from influxdb_client.domain.write_precision import _WritePrecision -EPOCH: Incomplete +_Value: TypeAlias = Incomplete +_Time: TypeAlias = Integral | str | datetime | timedelta + +EPOCH: datetime DEFAULT_WRITE_PRECISION: _WritePrecision class Point: @staticmethod - def measurement(measurement): ... + def measurement(measurement: str) -> Point: ... @staticmethod - def from_dict(dictionary: dict[Incomplete, Incomplete], write_precision: _WritePrecision = ..., **kwargs): ... - def __init__(self, measurement_name) -> None: ... - def time(self, time, write_precision=...): ... - def tag(self, key, value): ... - def field(self, field, value): ... - def to_line_protocol(self, precision: Incomplete | None = ...): ... + def from_dict( + dictionary: SupportsGetItem[str, Any], + write_precision: _WritePrecision = ..., + *, + record_measurement_name: str | None = ..., + record_measurement_key: str = ..., + record_tag_keys: Iterable[str] | None = ..., + record_field_keys: Iterable[str] | None = ..., + record_time_key: str = ..., + fields: SupportsItems[str, Literal["int", "uint", "float"]] = ..., + ) -> Point: ... + def __init__(self, measurement_name: str) -> None: ... + def time(self: Self, time: _Time, write_precision: _WritePrecision = ...) -> Self: ... + def tag(self: Self, key: str, value: _Value) -> Self: ... + def field(self: Self, field: str, value: _Value) -> Self: ... + def to_line_protocol(self, precision: _WritePrecision | None = ...) -> str: ... @property - def write_precision(self): ... + def write_precision(self) -> _WritePrecision: ... @classmethod - def set_str_rep(cls, rep_function) -> None: ... + def set_str_rep(cls, rep_function: Any) -> None: ...