Commit 97159ce3 authored by julian.gethmann's avatar julian.gethmann

WIP: Add type annotation

parent 757f1d86
......@@ -16,7 +16,7 @@ import json
from collections import namedtuple
from os import path
from sys import version_info
from typing import List, Optional, Union
from typing import List, Optional, Tuple, Union # flake8: noqa
from cassandra import __version__
......@@ -232,7 +232,7 @@ class CassandraHelper(object):
@staticmethod
def cassandra_json_to_timeseries(json_data):
# type(List[str]) -> Tuple[List[datetime.datetime], List[Union[List[float], float]]]
# type: (List[Optional[Dict[str, Union[int, Dict[str, str]]]]]) -> Tuple[List[datetime.datetime], List[Union[List[float], float]]]
"""Return lists of timestamps and values for given Cassandra's JSON data.
Args:
......@@ -346,6 +346,7 @@ class Cassandra(object):
self.json_file = path.join(directory, self.json_filename)
def __enter__(self):
# type: (Cassandra) -> str
""" ..versionadded:: 0.3 """
import tempfile
self.directory = tempfile.mkdtemp()
......@@ -353,12 +354,14 @@ class Cassandra(object):
return self.get_json_local()
def __exit__(self, ctx_type, ctx_value, ctx_traceback):
# type: (Cassandra, Optional[Exception], Optional[str], Optional[TracebackType]) -> None
""" ..versionadded:: 0.3 """
from shutil import rmtree
rmtree(self.directory)
@staticmethod
def check_connection():
# type: () -> bool
"""Return if the connection is ok or not
Returns:
......@@ -379,6 +382,7 @@ class Cassandra(object):
return ok
def gen_url(self):
# type: (Cassandra) -> str
"""Return the URL to be fetched from Cassandra.
If count is `None` then the count parameter is not included in the URL
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment