fixing type hints

This commit is contained in:
Mose Mueller 2024-02-13 11:17:43 +01:00
parent d14805ee7f
commit f708b6d159
2 changed files with 13 additions and 2 deletions

View File

@ -3,6 +3,12 @@ from __future__ import annotations
import logging import logging
from typing import TYPE_CHECKING, Any, NamedTuple from typing import TYPE_CHECKING, Any, NamedTuple
try:
from typing import Self # type: ignore
except ImportError:
from typing_extensions import Self
from confz import FileSource from confz import FileSource
from influxdb_client import ( from influxdb_client import (
Bucket, Bucket,
@ -77,7 +83,7 @@ class InfluxDBSession:
self._write_api: WriteApi self._write_api: WriteApi
self._buckets_api: BucketsApi self._buckets_api: BucketsApi
def __enter__(self) -> InfluxDBSession: def __enter__(self) -> Self:
self._client = InfluxDBClient(url=self.url, token=self.token, org=self.org) self._client = InfluxDBClient(url=self.url, token=self.token, org=self.org)
self._write_api = self._client.write_api(write_options=SYNCHRONOUS) # type: ignore self._write_api = self._client.write_api(write_options=SYNCHRONOUS) # type: ignore
return self return self

View File

@ -6,6 +6,11 @@ import logging
import re import re
from typing import TYPE_CHECKING, Any from typing import TYPE_CHECKING, Any
try:
from typing import Self # type: ignore
except ImportError:
from typing_extensions import Self
from confz import FileSource from confz import FileSource
from dateutil.parser import ParserError, parse # type: ignore from dateutil.parser import ParserError, parse # type: ignore
from sqlmodel import Session, SQLModel, create_engine from sqlmodel import Session, SQLModel, create_engine
@ -155,7 +160,7 @@ class PostgresDatabaseSession(Session):
) )
) )
def __enter__(self) -> PostgresDatabaseSession: def __enter__(self) -> Self:
"""Begins the runtime context related to the database session.""" """Begins the runtime context related to the database session."""
super().__enter__() super().__enter__()