Commit b0ccaa82 authored by julian.gethmann's avatar julian.gethmann

WIP: Fix some issues with mypy/PEP484

parent 97159ce3
......@@ -16,7 +16,7 @@ import json
from collections import namedtuple
from os import path
from sys import version_info
from typing import List, Optional, Tuple, Union # flake8: noqa
from typing import Dict, List, Optional, Tuple, Union # flake8: noqa
from cassandra import __version__
......@@ -156,7 +156,7 @@ class CassandraHelper(object):
@staticmethod
def cassandra_time2dt(time_string):
# type: (str) -> datetime.datetime
# type: (Union[str,datetime.datetime]) -> datetime.datetime
"""Return a :obj:`datetime.datetime` for a given date in cassandra's format
Args:
......@@ -291,6 +291,7 @@ class Cassandra(object):
json_filename (str): filename to which the JSON data is written/read
HOSTNAME (str): hostname of the Cassandra server
PORT (int): port on which the Cassandra server runs
timeout (int): timeout for the HTTP requests
Can also be used as a context manager that returns the :func:`get_json_local`.
......@@ -344,6 +345,7 @@ class Cassandra(object):
count=self.count,
)
self.json_file = path.join(directory, self.json_filename)
self.timeout = None # type: Optional[int]
def __enter__(self):
# type: (Cassandra) -> str
......@@ -453,7 +455,7 @@ class Cassandra(object):
return json_data
def dump_cassandra_data(self):
# type: (bool) -> str
# type: (...) -> str
"""Dump the JSON file to a file named like the PV and time that is returned
Dump a JSON file fetched from the Cassandra `host` and return its name.
......
......@@ -10,6 +10,7 @@
Import CSS exported data and some helper functions to deal with these kind of data.
"""
from datetime import datetime
from typing import AnyStr, List, Text, Tuple # flake8: noqa
import numpy as np
......@@ -22,6 +23,7 @@ except ImportError:
def _header(filename):
# type: (str) -> Tuple[List[str], int]
""" Return ...
Args:
......@@ -50,7 +52,7 @@ def _header(filename):
def _comma(obj):
# type: (str) -> float
# type: (AnyStr) -> float
""" Convert object/string with `,` as decimal marker to float
If the value is a string, but not convertible to a float, `np.nan` is returned.
......@@ -64,7 +66,7 @@ def _comma(obj):
3.14
"""
try:
obj = obj.decode("utf-8")
obj = obj.decode("utf-8") # type: Text
except AttributeError:
pass
try:
......
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