question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Literal type of engine argument incompatible with custom backends

See original GitHub issue

What is your issue?

In the recent typing improvements the engine argument for open_dataset was changed from Str to a Literal of xarrays internal engines. This will cause problems for all third party backend plugins.

We have several possibilities:

  1. I don’t know if there is a way to know installed backends at type checking time. Then we could add this support. (I doubt this is possible seeing how dynamic these imports are)
  2. Is it possible for these plugins to tell type checkers that their engine is valid, i.e. change the type signature of xarrays function? Then we should add a how-to in the docu.
  3. Else we should probably revert to using Str.

Any typing experts here that could help?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
headtr1ckcommented, May 24, 2022

Or we could just have a global variable like SUPPORTED_BACKENDS: List[str] = Literal['netcdf4', 'zarr'] which is appended to when a user registers a new backend?

If you know how that works statically, I don’t see a way to do that. You can only get dynamic content from static types and not the other way around.

0reactions
headtr1ckcommented, May 24, 2022

Ok, let’s keep this issue open for a bit in case someone still finds a solution. But we should go back to Str before releasing the next version.

Read more comments on GitHub >

github_iconTop Results From Across the Web

pandas/frame.py at main · pandas-dev/pandas - GitHub
error: Argument 3 to "nested_data_to_arrays" has incompatible. # type ... The type of the key-value pairs can be customized with the parameters.
Read more >
The Comprehensive Guide to mypy - DEV Community ‍ ‍
Mypy is a static type checker for Python. It acts as a linter, that allows you to write statically typed code, and verify...
Read more >
Migrating to Apollo Server 4 - Apollo GraphQL Docs
In Apollo Server 4, the context function is a named argument passed into your web integration function (e.g., expressMiddleware or startStandaloneServer ).
Read more >
JavaScript policy runtime error troubleshooting | Apigee Edge
Type error. The error type TypeError is thrown when: An operand or argument passed to a function is incompatible with the type expected...
Read more >
Column Elements and Expressions
Return a literal clause, bound to a bind parameter. ... Unsupported backends will raise a subclass of DBAPIError when such an expression is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found