GithubHelp home page GithubHelp logo

polugins's People

Contributors

github-actions[bot] avatar stefanbras avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

arengard

polugins's Issues

How should an applications own namespaces be registered?

It can either be done inline as it is now, with actual python imports to specify which namespaces to add OR it could be specified externally in pyproject.toml or something, similar to how the entry points are collected. (Entry points could be used in the same way as external packages, but that can be a bit annoying. See the the README.)

On one hand, it's annoying to have to use metadata if you only care about registering the namespaces and not typing. On the other hand, the type generation will be way more cumbersome if we have to try and parse arbitrary python code to resolve imports.

Consider making `register_namespaces` optionally generate the types

Right now we can't generate types for namespaces registered through either an import path as string or directly (because we'd have to scan through the code and parse the AST and all kind of too-much-work stuff)

However we could maybe just dump the types at runtime, if for example an ENV var was set. Then you could set it as a flag when running pytest or something, or have a standalone script that just registers namespaces.

Type stubs for yanked versions

We're using pip index versions polars to get the available versions when generating the type stubs, but this does not show yanked versions.

We probably still want those.

Testing

Various test improvements

  • Nox
  • Coverage
  • CLI testing
  • Polars api extension context - there's no way to unregister namespaces, so every test is dirty

FIx stub gen

It's failing because I forgot to update a lock file (and maybe because poetry had a new version published?)

Type stubs for version 0.20.3 does not exist

hey

sorry for the delay in trying this - just gave it a go, and got

ValueError: Type stubs for version 0.20.3 does not exist. This is usually because the version has been yanked. Feel free to create an issue if you want to generate types for this version

I ran polugins stubs from the root of polars-xdt

Loosen dependencies

The dependencies usually use the latest version, but can be loosened.

  • importlib-metadata = "^6.6.0"
  • importlib-resources = "^5.12.0"
  • typing-extensions = "^4.6.3"

OLD STUBS

is there a way to keep up with the weekly releases of polars ;)

olugins_type_gen.cli.MissingVersionException: Type stubs for version 0.20.10 does not exist. This is usually because the version has been yanked or because it's new. Feel free to create an issue if you want types for this version.

CI/CD

  • Release
  • Test
  • Lint
  • Make PR when new polars version is released

How to register expressions?

I've tried making a Python file t.py with

from polugins import register_namespaces
import polars as pl
from polars_xdt import ExprXDTNamespace

register_namespaces(
    expression_namespaces={
        'xdt': ExprXDTNamespace,
    },
  )

pl.col('a').xdt.format_localized('%a')

If I type check it, I get:

$ mypy t.py
t.py:1: error: Skipping analyzing "polugins": module is installed, but missing library stubs or py.typed marker  [import-untyped]
t.py:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
t.py:11: error: "Expr" has no attribute "xdt"; maybe "dt"?  [attr-defined]
Found 2 errors in 1 file (checked 1 source file)

If I run it, I get:

$ python  t.py
/home/marcogorelli/tmp/.venv/lib/python3.10/site-packages/polugins/_types.py:35: UserWarning: Overriding existing custom namespace 'xdt' (on 'Expr')
  return pl.api.register_expr_namespace(name)(namespace)  # type: ignore

Am I doing something wrong?

Typeguard in stubs

Right now I just put in imports in the type stubs, but these are only there at type checking-time and not at run time.

Load from env vars

I'm still not sure what the best interface is, so lets just put in lots of ways and see what sticks.

We could have a env var structure like

POLUGINS_<class>_<name> = <module_path>:<NamespaceCLass>

For example

POLUGINS_lazyframe_custom = mypackage.submodule:CustomNameSpace

Would add the namespace CustomNameSpace under pl.LazyFrame.custom.

Then register_namespaces should have a register_env_vars: bool too

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.