Skip to content

Commit

Permalink
Fixing a couple type problems: how I would address most of #381 (#382)
Browse files Browse the repository at this point in the history
* Create py.typed

Signed-off-by: wyattscarpenter <wyattscarpenter@gmail.com>

* add -> Connection annotation

Signed-off-by: wyattscarpenter <wyattscarpenter@gmail.com>

* massage the code to appease the particular version of the project's mypy deps

Signed-off-by: wyattscarpenter <wyattscarpenter@gmail.com>

* fix circular import problem

Signed-off-by: wyattscarpenter <wyattscarpenter@gmail.com>

---------

Signed-off-by: wyattscarpenter <wyattscarpenter@gmail.com>
  • Loading branch information
wyattscarpenter authored Apr 2, 2024
1 parent 7fade51 commit 6e0fb78
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Empty file added src/databricks/py.typed
Empty file.
8 changes: 7 additions & 1 deletion src/databricks/sql/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@

import re

from typing import TYPE_CHECKING

if TYPE_CHECKING:
# Use this import purely for type annotations, a la https://mypy.readthedocs.io/en/latest/runtime_troubles.html#import-cycles
from .client import Connection


class RedactUrlQueryParamsFilter(logging.Filter):
pattern = re.compile(r"(\?|&)([\w-]+)=([^&]+)")
Expand Down Expand Up @@ -78,7 +84,7 @@ def TimestampFromTicks(ticks):
return Timestamp(*time.localtime(ticks)[:6])


def connect(server_hostname, http_path, access_token=None, **kwargs):
def connect(server_hostname, http_path, access_token=None, **kwargs) -> "Connection":
from .client import Connection

return Connection(server_hostname, http_path, access_token, **kwargs)

0 comments on commit 6e0fb78

Please sign in to comment.