Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move py.typed to correct places #403

Merged
merged 7 commits into from
Jul 2, 2024
Merged

move py.typed to correct places #403

merged 7 commits into from
Jul 2, 2024

Conversation

wyattscarpenter
Copy link
Contributor

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, so I added the py.typed file to the top-level folder (the namespace). 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, leading to unnecessary type errors in those other packages. This commit moves the py.typed file to the correct places, the submodule folders, fixing that problem.

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 <wyattscarpenter@gmail.com>
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 <wyattscarpenter@gmail.com>
…led (no mypy cache directory)'; see python/mypy#10768 (comment)

Signed-off-by: wyattscarpenter <wyattscarpenter@gmail.com>
Signed-off-by: wyattscarpenter <wyattscarpenter@gmail.com>
@kravets-levko
Copy link
Contributor

Hi @wyattscarpenter! CI now reports this error: src/databricks/sql/cloudfetch/downloader.py: error: Source file found twice under different module names: "downloader" and "databricks.sql.cloudfetch.downloader" - do you have any ideas what causes this?

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 <wyattscarpenter@gmail.com>
@wyattscarpenter
Copy link
Contributor Author

@kravets-levko the "Source file found twice under different module names" error is, ultimately, caused by mypy not dealing with the namespaces correctly. It's either a historical bug or behavior they decided to change later, since it actually works fine without workarounds or flags on the latest version of mypy: https://github.com/wyattscarpenter/databricks-sql-python/tree/upgrade_mypy (I'm thinking I'll do a pr from that branch later, since the version upgrade touches a number of other files and therefore might be inconvenient to review at the same time as this pr; but I could also make squash it into a commit in this pr if you would prefer.)

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 <wyattscarpenter@gmail.com>
@kravets-levko kravets-levko self-requested a review July 1, 2024 15:11
"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 <levko.ne@gmail.com>
Signed-off-by: wyattscarpenter <wyattscarpenter@gmail.com>
@kravets-levko kravets-levko merged commit f53aa37 into databricks:main Jul 2, 2024
11 checks passed
@kravets-levko
Copy link
Contributor

Thank you @wyattscarpenter!

@wyattscarpenter
Copy link
Contributor Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants