Skip to content

Commit f53aa37

Browse files
move py.typed to correct places (#403)
* move py.typed to correct places https://peps.python.org/pep-0561/ says 'For namespace packages (see PEP 420), the py.typed file should be in the submodules of the namespace, to avoid conflicts and for clarity.'. Previously, when I added the py.typed file to this project, #382 , I was unaware this was a namespace package (although, curiously, it seems I had done it right initially and then changed to the wrong way). As PEP 561 warns us, this does create conflicts; other libraries in the databricks namespace package (such as, in my case, databricks-vectorsearch) are then treated as though they are typed, which they are not. This commit moves the py.typed file to the correct places, the submodule folders, fixing that problem. Signed-off-by: wyattscarpenter <[email protected]> * change target of mypy to src/databricks instead of src. I think this might fix the CI code-quality checks failure, but unfortunately I can't replicate that failure locally and the error message is unhelpful Signed-off-by: wyattscarpenter <[email protected]> * Possible workaround for bad error message 'error: --install-types failed (no mypy cache directory)'; see python/mypy#10768 (comment) Signed-off-by: wyattscarpenter <[email protected]> * fix invalid yaml syntax Signed-off-by: wyattscarpenter <[email protected]> * Best fix (#3) Fixes the problem by cding and supplying a flag to mypy (that mypy needs this flag is seemingly fixed/changed in later versions of mypy; but that's another pr altogether...). Also fixes a type error that was somehow in the arguments of the program (?!) (I guess this is because you guys are still using implicit optional) --------- Signed-off-by: wyattscarpenter <[email protected]> * return the old result_links default (#5) Return the old result_links default, make the type optional, & I'm pretty sure the original problem is that add_file_links can't take a None, so these statements should be in the body of the if-statement that ensures it is not None Signed-off-by: wyattscarpenter <[email protected]> * Update src/databricks/sql/utils.py "self.download_manager is unconditionally used later, so must be created. Looks this part of code is totally not covered with tests 🤔" Co-authored-by: Levko Kravets <[email protected]> Signed-off-by: wyattscarpenter <[email protected]> --------- Signed-off-by: wyattscarpenter <[email protected]> Co-authored-by: Levko Kravets <[email protected]>
1 parent a5b1ab0 commit f53aa37

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

.github/workflows/code-quality-checks.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,7 @@ jobs:
160160
# mypy the code
161161
#----------------------------------------------
162162
- name: Mypy
163-
run: poetry run mypy --install-types --non-interactive src
163+
run: |
164+
cd src # Need to be in the actual databricks/ folder or mypy does the wrong thing.
165+
mkdir .mypy_cache # Workaround for bad error message "error: --install-types failed (no mypy cache directory)"; see https://github.com/python/mypy/issues/10768#issuecomment-2178450153
166+
poetry run mypy --config-file ../pyproject.toml --install-types --non-interactive --namespace-packages databricks
File renamed without changes.

src/databricks/sql/utils.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from collections.abc import Iterable
88
from decimal import Decimal
99
from enum import Enum
10-
from typing import Any, Dict, List, Union
10+
from typing import Any, Dict, List, Optional, Union
1111
import re
1212

1313
import lz4.frame
@@ -134,7 +134,7 @@ def __init__(
134134
schema_bytes,
135135
max_download_threads: int,
136136
start_row_offset: int = 0,
137-
result_links: List[TSparkArrowResultLink] = None,
137+
result_links: Optional[List[TSparkArrowResultLink]] = None,
138138
lz4_compressed: bool = True,
139139
description: List[List[Any]] = None,
140140
):
@@ -168,11 +168,10 @@ def __init__(
168168
result_link.startRowOffset, result_link.rowCount
169169
)
170170
)
171-
172171
self.download_manager = ResultFileDownloadManager(
173172
self.max_download_threads, self.lz4_compressed
174173
)
175-
self.download_manager.add_file_links(result_links)
174+
self.download_manager.add_file_links(result_links or [])
176175

177176
self.table = self._create_next_table()
178177
self.table_row_index = 0

src/databricks/sqlalchemy/py.typed

Whitespace-only changes.

0 commit comments

Comments
 (0)