Skip to content

Commit

Permalink
Typings (#1163)
Browse files Browse the repository at this point in the history
  • Loading branch information
olivakar authored Jan 29, 2024
1 parent d559dce commit 62690bd
Show file tree
Hide file tree
Showing 25 changed files with 390 additions and 270 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ repos:
hooks:
- id: black
language_version: python3
- repo: https://gitlab.com/pycqa/flake8
- repo: https://github.com/pycqa/flake8
rev: 3.9.1 # Use the ref you want to point at
hooks:
- id: flake8
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The Azure IoT Device library is available on PyPI:
pip install azure-iot-device
```

Python 3.6 or higher is required in order to use the library
Python 3.7 or higher is required in order to use the library

## Using the library
API documentation for this package is available via [**Microsoft Docs**](https://docs.microsoft.com/python/api/azure-iot-device/azure.iot.device?view=azure-python).
Expand Down
2 changes: 1 addition & 1 deletion azure-iot-device/azure/iot/device/common/http_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import logging
import ssl
import requests
import requests # type: ignore
from . import transport_exceptions as exceptions
from .pipeline import pipeline_thread

Expand Down
41 changes: 41 additions & 0 deletions azure-iot-device/azure/iot/device/custom_typing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
from typing import Any, Union, Dict, List, Tuple, Callable, Awaitable, TypeVar
from typing_extensions import TypedDict, ParamSpec


_P = ParamSpec("_P")
_R = TypeVar("_R")
FunctionOrCoroutine = Union[Callable[_P, _R], Callable[_P, Awaitable[_R]]]


# typing does not support recursion, so we must use forward references here (PEP484)
JSONSerializable = Union[
Dict[str, "JSONSerializable"],
List["JSONSerializable"],
Tuple["JSONSerializable", ...],
str,
int,
float,
bool,
None,
]
# TODO: verify that the JSON specification requires str as keys in dict. Not sure why that's defined here.


Twin = Dict[str, Dict[str, JSONSerializable]]
TwinPatch = Dict[str, JSONSerializable]


class StorageInfo(TypedDict):
correlationId: str
hostName: str
containerName: str
blobName: str
sasToken: str


ProvisioningPayload = Union[Dict[str, Any], str, int]
Loading

0 comments on commit 62690bd

Please sign in to comment.