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

Fixing a couple type problems: how I would address most of #381 #382

Merged
merged 4 commits into from
Apr 2, 2024
Merged

Fixing a couple type problems: how I would address most of #381 #382

merged 4 commits into from
Apr 2, 2024

Conversation

wyattscarpenter
Copy link
Contributor

@wyattscarpenter wyattscarpenter commented Mar 30, 2024

see #381

@benc-db
Copy link
Collaborator

benc-db commented Apr 1, 2024

What do the empty 'typed' files do?

@benc-db
Copy link
Collaborator

benc-db commented Apr 1, 2024

What do the empty 'typed' files do?
It looks like they fail our mypy step...do you have any suggestions on how to update the workflow so that this will pass?

@wyattscarpenter
Copy link
Contributor Author

wyattscarpenter commented Apr 1, 2024

The empty py.typed files are simply a python convention that allow typecheckers to use the type annotations of your package, when typechecking project that depend on your package. (Seems kind of redundant to me, but I didn't make the conventions!) https://peps.python.org/pep-0561/#packaging-type-information

I think probably the mypy step is failing for some other reason, because the error message says

error: --install-types failed (no mypy cache directory)
Error: Process completed with exit code 2.

Which seems unrelated. I'll see if I can replicate this on my machine, later.

Ah, hold on, the unrelated error message is a bug in mypy, so I will have to replicate this error on my machine, just to see what the actual error is!

There are also other errors above in the steps, but quite possibly those are unrelated.

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

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

wyattscarpenter commented Apr 1, 2024

I think the problems should be fixed now. It had to do with importing the type so that the typechecker could see it, while making sure not to cause a circular import. These commits can be squashed.

@benc-db
Copy link
Collaborator

benc-db commented Apr 1, 2024

Running integration tests, then will merge.

@benc-db benc-db merged commit 6e0fb78 into databricks:main Apr 2, 2024
13 checks passed
kravets-levko added a commit that referenced this pull request Jul 2, 2024
* 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 <wyattscarpenter@gmail.com>

* 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 <wyattscarpenter@gmail.com>

* Possible workaround for bad error message 'error: --install-types failed (no mypy cache directory)'; see python/mypy#10768 (comment)

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

* fix invalid yaml syntax

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

* 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 <wyattscarpenter@gmail.com>

* 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 <wyattscarpenter@gmail.com>

* 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 <levko.ne@gmail.com>
Signed-off-by: wyattscarpenter <wyattscarpenter@gmail.com>

---------

Signed-off-by: wyattscarpenter <wyattscarpenter@gmail.com>
Co-authored-by: Levko Kravets <levko.ne@gmail.com>
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