Type Hints - Core/Utils/Helpers Part 1 (#2592)

* Fix deprecated(moved) import

* Add util/dt typing

* Green on mypy util/dt

* Fix some errors

* First part of yping util/yaml

* Add more typing to util/yaml
This commit is contained in:
Fabian Heredia Montiel authored and Paulus Schoutsen committed 2016-07-23 11:07:08 -07:00
1 parent 34ca1dac7d
commit d4f78e8552
6 files changed
+96 -71

No files matched your search

+5 -3
View File
@@ -1,5 +1,5 @@
"""Helper methods for various modules."""
import collections
from collections.abc import MutableSet
from itertools import chain
import threading
import queue
@@ -12,6 +12,8 @@ import string
from functools import wraps
from types import MappingProxyType
from typing import Any
from .dt import as_local, utcnow
RE_SANITIZE_FILENAME = re.compile(r'(~|\.\.|/|\\)')
@@ -36,7 +38,7 @@ def slugify(text):
return RE_SLUGIFY.sub("", text)
def repr_helper(inp):
def repr_helper(inp: Any) -> str:
"""Help creating a more readable string representation of objects."""
if isinstance(inp, (dict, MappingProxyType)):
return ", ".join(
@@ -128,7 +130,7 @@ class OrderedEnum(enum.Enum):
return NotImplemented
class OrderedSet(collections.MutableSet):
class OrderedSet(MutableSet):
"""Ordered set taken from http://code.activestate.com/recipes/576694/."""
def __init__(self, iterable=None):