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

[Fix] Use correct optional typing in WorkspaceClient for mypy #760

Merged
merged 1 commit into from
Sep 13, 2024

Conversation

nfx
Copy link
Contributor

@nfx nfx commented Sep 13, 2024

Without this change, the SDK is not very mypy-compatible. This PR fixes arg-type check:

cmd [3] | mypy --disable-error-code 'annotation-unchecked' --exclude 'tests/resources/*' --exclude dist .
error: Argument "auth_type" to "WorkspaceClient" has incompatible type "str | None"; expected "str"  [arg-type]
error: Argument "token" to "WorkspaceClient" has incompatible type "str | None"; expected "str"  [arg-type]

Optional[X] is py3.8 and py3.9 way of expressing optional types, but in py3.10+ it gets transformed into a union type of X | None, which is not supported by py3.9. py3.9 EOL is 31 Oct 2025, so we have to deal with it somehow until then.

Without this change, the SDK is not very `mypy`-compatible. This PR fixes `arg-type` check:

```
cmd [3] | mypy --disable-error-code 'annotation-unchecked' --exclude 'tests/resources/*' --exclude dist .
error: Argument "auth_type" to "WorkspaceClient" has incompatible type "str | None"; expected "str"  [arg-type]
error: Argument "token" to "WorkspaceClient" has incompatible type "str | None"; expected "str"  [arg-type]
```

`Optional[X]` is py3.8 and py3.9 way of expressing optional types, but in py3.10+ it gets transformed into a union type of `X | None`, which is not supported by py3.9. py3.9 EOL is 31 Oct 2025, so we have to deal with it somehow until then.
@mgyucht mgyucht added this pull request to the merge queue Sep 13, 2024
Merged via the queue into databricks:main with commit c3aad28 Sep 13, 2024
14 checks passed
@nfx nfx deleted the fix/mypy-correctness branch September 13, 2024 09:01
tanmay-db added a commit that referenced this pull request Sep 16, 2024
### New Features and Improvements

 * Support Models in `dbutils.fs` operations ([#750](#750)).

### Bug Fixes

 * Do not specify --tenant flag when fetching managed identity access token from the CLI ([#748](#748)).
 * Fix deserialization of 401/403 errors ([#758](#758)).
 * Use correct optional typing in `WorkspaceClient` for `mypy` ([#760](#760)).
github-merge-queue bot pushed a commit that referenced this pull request Sep 17, 2024
### New Features and Improvements

* Support Models in `dbutils.fs` operations
([#750](#750)).


### Bug Fixes

* Do not specify --tenant flag when fetching managed identity access
token from the CLI
([#748](#748)).
* Fix deserialization of 401/403 errors
([#758](#758)).
* Use correct optional typing in `WorkspaceClient` for `mypy`
([#760](#760)).
aravind-segu pushed a commit to aravind-segu/databricks-sdk-py that referenced this pull request Sep 18, 2024
…tabricks#760)

Without this change, the SDK is not very `mypy`-compatible. This PR
fixes `arg-type` check:

```
cmd [3] | mypy --disable-error-code 'annotation-unchecked' --exclude 'tests/resources/*' --exclude dist .
error: Argument "auth_type" to "WorkspaceClient" has incompatible type "str | None"; expected "str"  [arg-type]
error: Argument "token" to "WorkspaceClient" has incompatible type "str | None"; expected "str"  [arg-type]
```

`Optional[X]` is py3.8 and py3.9 way of expressing optional types, but
in py3.10+ it gets transformed into a union type of `X | None`, which is
not supported by py3.9. py3.9 EOL is 31 Oct 2025, so we have to deal
with it somehow until then.
aravind-segu pushed a commit to aravind-segu/databricks-sdk-py that referenced this pull request Sep 18, 2024
### New Features and Improvements

* Support Models in `dbutils.fs` operations
([databricks#750](databricks#750)).


### Bug Fixes

* Do not specify --tenant flag when fetching managed identity access
token from the CLI
([databricks#748](databricks#748)).
* Fix deserialization of 401/403 errors
([databricks#758](databricks#758)).
* Use correct optional typing in `WorkspaceClient` for `mypy`
([databricks#760](databricks#760)).
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