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

Permission to generate stubs for structlog in typeshed #165

Closed
waseem18 opened this issue Jun 7, 2018 · 14 comments
Closed

Permission to generate stubs for structlog in typeshed #165

waseem18 opened this issue Jun 7, 2018 · 14 comments

Comments

@waseem18
Copy link

waseem18 commented Jun 7, 2018

Hi Hynek,

I would like to add stubs for structlog to https://github.com/python/typeshed, a repository used to store PEP 484 type signatures for the Python stdlib and popular third party libraries. As per PEP 484, permission is required from the library owner before merging type signatures into typeshed - https://www.python.org/dev/peps/pep-0484/#the-typeshed-repo

These stubs will be used by mypy and Pycharm. I'll start working on creating stubs after I get permission from you and do let me know if you have any suggestions.

Thanks

@hynek
Copy link
Owner

hynek commented Jun 7, 2018

Actually I would prefer if you’d contribute them to structlog proper! Packages can ship their own stubs now.

If you’d agree to do that, I’d add an AbstractBoundLogger first.

@waseem18
Copy link
Author

waseem18 commented Jun 7, 2018

@hynek Good to know that packages can ship their own stubs now. Will surely go in that way.

However I didn't get what you meant by

If you’d agree to do that, I’d add an AbstractBoundLogger first.

@hynek
Copy link
Owner

hynek commented Jun 7, 2018

Re: AbstractBoundLogger: I suspect it’s easier to build stubs if there’s an abstract interface that fits all bound loggers.

The docs for stubs-via-package are here btw: http://mypy.readthedocs.io/en/latest/installed_packages.html

@waseem18
Copy link
Author

waseem18 commented Jun 7, 2018

@hynek Thanks for the link

It would surely be efficient if there's an abstract interface for bound loggers.

So what all loggers do you think would be better to abstract out?

@hynek
Copy link
Owner

hynek commented Jun 8, 2018

So I just noticed that untypically for me, I already have a base class that all loggers derive from: structlog.BoundLoggerBase!

So just use that, I may or may not add an abc at some point, but it’s nothing you need to wait for.


One more thing: unless you can come up with a good reason, I’d say we don’t use a .pyi file and write the annotations into the code in Python 2-style: http://mypy.readthedocs.io/en/latest/python2.html

Let me know if you need anything or anything is unclear.

@hynek
Copy link
Owner

hynek commented Jul 5, 2018

Any progress? 😇

@haizaar
Copy link

haizaar commented Jun 14, 2019

Good day guys,
Do you know if there was any progress on this issue?

@sebpiq-kialo
Copy link

@waseem18 any progress on this ?

@waseem18
Copy link
Author

Sorry folks, I couldn't get to work on it. Anyone interested can pick it up.

Thanks

@sebpiq-kialo
Copy link

@waseem18 ok thanks for the update. I might pick it :)

@lg-kialo
Copy link

@hynek

Concerning the preference of Python 2-style type comments over .pyi stubs: with type comments, it's not possible (AFAIK) to have conditional typing based on the Python version.
This seems to be a problem, given that the types of the logging package are different in Python 2 and 3 (see link), making it difficult-if-not-impossible to properly add typings to structlog.
Is this a good enough reason to switch to .pyi typings?

@hynek
Copy link
Owner

hynek commented Aug 29, 2019

I honestly don't have too strong feelings about it, so if you have good reasons, go wild.

@lg-kialo lg-kialo mentioned this issue Sep 4, 2019
sbdchd added a commit to chdsbd/kodiak that referenced this issue Aug 11, 2020
Now we explicitly ignore specific imports instead of a blanket ignore
on all missing types.

Upgraded databases and pytest to get their latest versions which include
types, for the rest we're ignoring them explicitly.
see #485

- arrow

  doesn't have types but we can replace it with std library calls

- requests_async

  deprecated in favor of httpx, so we'd need to upgrade to get types.
  The API of httpx is a little different as well.

- structlog

  doesn't have types currently

  hynek/structlog#165

- rure

  No stubs yet

  davidblewett/rure-python#23

- pytest_mock

  types recently added to the typeshed so we'll need to wait for the next
  release of mypy.

  pytest-dev/pytest-mock#152

- markdown_html_finder

  Wrapper around some Rust code. Needs stubs to be added.

  chdsbd/markdown-html-finder#5

- asyncio_redis

  We're our own fork of it, but adding types would be rather manual.
  Granted we aren't using that much of the API surface.

  https://github.com/chdsbd/asyncio-redis

- zstandard

  No stubs yet, so we're ignoring for the time being

  indygreg/python-zstandard#120

- inflection

  Types, but I think they're misconfigured, once they're fixed we can
  unignore.

  jpvanhal/inflection#49

- django

  Need to setup django-stubs for this to work since django doesn't have
  any static types.

  https://github.com/TypedDjango/django-stubs

- dj_database_url

  Doesn't have any static types yet

  jazzband/dj-database-url#135

- responses

  No types yet

  getsentry/responses#339

- stripe

  Plan for types, but they don't exist currently

  stripe/stripe-python#650
kodiakhq bot pushed a commit to chdsbd/kodiak that referenced this issue Aug 11, 2020
Now we explicitly ignore specific imports instead of a blanket ignore
on all missing types.

Upgraded databases and pytest to get their latest versions which include
types, for the rest we're ignoring them explicitly.
see #485

- arrow

  doesn't have types but we can replace it with std library calls

- requests_async

  deprecated in favor of httpx, so we'd need to upgrade to get types.
  The API of httpx is a little different as well.

- structlog

  doesn't have types currently

  hynek/structlog#165

- rure

  No stubs yet

  davidblewett/rure-python#23

- pytest_mock

  types recently added to the typeshed so we'll need to wait for the next
  release of mypy.

  pytest-dev/pytest-mock#152

- markdown_html_finder

  Wrapper around some Rust code. Needs stubs to be added.

  chdsbd/markdown-html-finder#5

- asyncio_redis

  We're using our own fork of it, but adding types would be rather manual.
  Granted we aren't using that much of the API surface.

  https://github.com/chdsbd/asyncio-redis

- zstandard

  No stubs yet, so we're ignoring for the time being

  indygreg/python-zstandard#120

- inflection

  Types, but I think they're misconfigured, once they're fixed we can
  unignore.

  jpvanhal/inflection#49

- django

  Need to setup django-stubs for this to work since django doesn't have
  any static types.

  https://github.com/TypedDjango/django-stubs

- dj_database_url

  Doesn't have any static types yet

  jazzband/dj-database-url#135

- responses

  No types yet

  getsentry/responses#339

- stripe

  Plan for types, but they don't exist currently

  stripe/stripe-python#650
@paravoid
Copy link

paravoid commented Apr 9, 2021

Isn't this issue moot given #282 was merged?

@hynek
Copy link
Owner

hynek commented Apr 9, 2021

Very much so! I wasn't aware it's still open – thank you for pointing it out.

@hynek hynek closed this as completed Apr 9, 2021
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

No branches or pull requests

6 participants