Находки в опенсорсе: Python
1.06K subscribers
5 photos
348 links
Легкие задачки в опенсорсе из мира Python

Чат: @opensource_findings_chat
Download Telegram
Еще одна небольшая правка по документации FastStream – нужно заменить использование f-строк в логировании в примерах кода документации. В Issue приведен конкретный пример, но нужно найти все такие места и исправить их.

https://github.com/airtai/faststream/issues/2122

#documentation #faststream
https://github.com/ag2ai/faststream/issues/2180

Очень простой Issue на расширение документации об использовании RPC в FastStream. Нужно добавить примеры использования Response классов и того, как должен выглядить subscriber, способный ответить на сообщение

#documentation #faststream
🚀 New issue to wemake-services/django-modern-rest by @sobolevn
📝 Figure out why sphinx does not link HttpResponse as a return type (#153)

See https://github.com/wemake-services/django-modern-rest/blob/7aa23316219d4226d7c49435f9b028130f8c5dbc/docs/conf.py#L98-L99

When make -C docs clean html is generated without this line, sphinx produces:

django-modern-rest/django_modern_rest/errors.py:docstring of django_modern_rest.errors.global_error_handler:1: WARNING: py:class reference target not found: django.http.response.HttpResponse [ref.class]
django-modern-rest/django_modern_rest/endpoint.py:docstring of django_modern_rest.endpoint.Endpoint.__call__:1: WARNING: py:class reference target not found: django.http.response.HttpResponse [ref.class]
django-modern-rest/django_modern_rest/endpoint.py:docstring of django_modern_rest.endpoint.Endpoint.handle_async_error:1: WARNING: py:class reference target not found: django.http.response.HttpResponse [ref.class]
django-modern-rest/django_modern_rest/endpoint.py:docstring of django_modern_rest.endpoint.Endpoint.handle_error:1: WARNING: py:class reference target not found: django.http.response.HttpResponse [ref.class]


This does not seem right, because everything is configure: intersphinx, imports, etc.

• Links in the form of inline :class: roles are rendered correctly

<img width="721" height="115" alt="Image" src="https://github.com/user-attachments/assets/91a0e5ee-90de-4e04-ae52-58514cc275f4" />

• The link in the annotations is not generated

<img width="737" height="377" alt="Image" src="https://github.com/user-attachments/assets/9ab218c1-0153-45f4-836f-e2d2eaaec92b" />

#documentation #helpwanted #goodfirst_issue

sent via relator
❤1
New issue to wemake-services/django-modern-rest by @sobolevn
Split code from `middleware.rst` into its own example file
(#186)

We store our examples as independent files, so it would be easier for us to work with them: type checking, linting, etc.

Right now middleware.rst has a lot of code with no examples. We need to create a new example/middleware/<example_name>.py and split the code.

#django_modern_rest #documentation #good_first_issue #help_wanted

sent via relator
New issue to wemake-services/django-modern-rest by @sobolevn
Customize `.. literalinclude` directive to automatically create links to the source files
(#191)

Some examples have a big number of import statements that take around 30%-50% of the whole example. We can use :lines: NUM- to hide imports, but, we still want to show the whole file when needed.

To fix this I propose adding a sphinx custom directive called .. literalincludelinked, which will produce

🖼️Image

Here are some basic examples of how to do something similar:
https://chatgpt.com/share/68ff5943-c07c-8009-8ae1-cc6520b452d7

PRs are very welcome!

#django_modern_rest #documentation #help_wanted #enhancement #good_first_issue

sent via relator
🚀 New issue to wemake-services/django-modern-rest by @sobolevn
📝 Add `:language: python` to every single `.. literalinclude` (#458)


Sometimes without :language: python sphinx does not render code correctly. Example:

🖼️Image

This happens because .. literalinclude there does not have :language: python

django-modern-rest/docs/pages/using-controller.rst

Lines 171 to 178 in d654770

We need to add it everywhere, where it is missing.


#documentation #good_first_issue #help_wanted #django_modern_rest
sent via relator
🚀 New issue to wemake-services/django-modern-rest by @sobolevn
📝 Deploy example application somewhere (#691)


We have an example Django app that we can deploy somewhere: https://github.com/wemake-services/django-modern-rest/tree/master/django_test_app

So, users would have a real life application to test and interact with.
I propose finding a service that:

• Is free for our case
• Can support deployments from GitHub Actions, so we can do that in CI as well
• Provides some kind of a permanent link, so we can share it
• Does not require complex deployment strategy

Like PythonAnywhere or Heroku or Vercel, etc.

Any help is appreciated.


#documentation #enhancement #good_first_issue #help_wanted #django_modern_rest
sent via relator
🚀 New issue to wemake-services/django-modern-rest by @sobolevn
📝 Support `openapi.yaml` (#745)


Litestar supports openapi.yaml view, so should we: https://docs.litestar.dev/latest/usage/openapi/ui_plugins.html

It should be only available if msgspec is installed, it can dump yaml with msgspec.yaml.
Everything else should be identical to openapi.json view.

This is a rather easy task, so new contributors are very welcome!


#documentation #good_first_issue #help_wanted #django_modern_rest
sent via relator
🔥1
🚀 New issue to wemake-services/django-modern-rest by @sobolevn
📝 Add docs and example about `django-health-check` integration (#831)


One can use https://github.com/codingjoe/django-health-check for health checks.
No special integration from our side is required.

This information can be added here: https://github.com/wemake-services/django-modern-rest/blob/master/docs/pages/integrations.rst


#documentation #enhancement #good_first_issue #help_wanted #django_modern_rest
sent via relator
🚀 New issue to wemake-services/django-modern-rest by @sobolevn
📝 Setup `lychee` link check tool for `pre-commit` (#1094)


It allows checking that all links are actually valid.
This will helps us finding dead / renamed links in the docs / code.

Hooks: https://github.com/lycheeverse/lychee/blob/master/.pre-commit-hooks.yaml
Docs: https://lychee.cli.rs/
Example config: https://github.com/msgspec/msgspec/blob/main/lychee.toml (but I would prefer to have it in the same folder as zizmor config is).


#documentation #feature #good_first_issue #help_wanted #django_modern_rest
sent via relator
🚀 New issue to ag2ai/faststream by @Lancetnik
📝 Bug: `redis.asyncio.Redis` type hint is not injected and fails validation (#3065)


Describe the bug

Annotating a handler argument with redis.asyncio.Redis — the obvious type for the connection — does not inject it. Instead the argument is treated as a message field and fails validation. The working annotation is faststream.redis.annotations.Redis, which is a different symbol with the same name.

The two names are identical, the import paths differ, and nothing in the failure points at the fix.

How to reproduce

from redis.asyncio import Redis

@broker.subscriber(stream=StreamSub("stream", group="group", consumer="consumer"))
async def handler(msg: RedisStreamMessage, redis: Redis) -> None:
...

vs. the version that works:

from faststream.redis.annotations import Redis

Real usage

A worker running faststream[redis] in production hit this and left a warning to their future selves in the handler docstring — SW-Maestro-17th-HBB/Kkori-AI, worker/src/main.py#L186-L191:

redis 는 FastStream 이 Context 로 넣어주는 커넥션이다. redis.asyncio.Redis 를 그대로 힌트로 쓰면 주입되지 않고 검증 오류가 난다.

("redis is the connection FastStream injects via Context. If you use redis.asyncio.Redis directly as the hint, it is not injected and you get a validation error.")

They also import it aliased — from faststream.redis.annotations import Redis as InjectedRedis — which suggests the name collision cost them enough to want it visible at the call site.

Expected behavior

Two things would each be enough on their own:

1. Documentation — the Redis pages show Redis in examples without making the import path explicit enough to survive a copy-paste. A short note that the annotation comes from faststream.redis.annotations, and that the same-named driver class will not work, closes it.
2. A better failure — when an argument is annotated with a broker client class that has a matching FastStream annotation, say so in the error instead of failing validation on a missing message field.

Additional context

Found by reading a real user's source, not reported by them — they worked around it and moved on, which is the reason this kind of papercut stays invisible. Companion finding: #3064.

@IvanKirpichnikov — the docs half is cheap; the error-message half is your call.


#bug #documentation #good_first_issue #redis #faststream #ag2ai
sent via relator
❤1
🚀 New issue to wemake-services/django-modern-rest by @sobolevn
📝 `RedirectTo` accepts protocol-relative URLs (#1326)


django-modern-rest/dmr/response.py

Lines 164 to 168 in a2d44b1

This might be a bug in Django as well.

>>> from urllib.parse import urlsplit
>>> urlsplit('//evil.example/x').scheme
''

So, the scheme check is skipped.
Django has https://github.com/django/django/blob/73cc09f14f13fedddc14d6ba5b287cb33c24e4a4/django/utils/http.py#L274 for this case.
And this is how it is used: https://github.com/django/django/blob/73cc09f14f13fedddc14d6ba5b287cb33c24e4a4/django/contrib/auth/views.py#L43-L59

We need to add docs about RedirectTo usage. So, developers will know that redirects to users' paths are not always safe.

(please, do not take this issue before the 1st of September)


#documentation #good_first_issue #help_wanted #security #opensource_september #django_modern_rest
sent via relator
🚀 New issue to wemake-services/django-modern-rest by @sobolevn
📝 Document that it is a good idea to remove expired tokens from `BlocklistedJWToken` (#1336)


Since they are expired anyway, they won't be usable for the auth.

So, there's no point in storing them.
The same can be said about Token model from dmr/security/token/app/models.py.

Document that adding a cron-job to remove old ones is probably worth it.
Show examples, what we can remove in both cases.

(please, do not take this issue before the 1st of September)


#documentation #good_first_issue #help_wanted #opensource_september #django_modern_rest
sent via relator
🚀 New issue to ag2ai/faststream by @davorrunje
📝 Docs: dealing with different schema registries (#1297)


It would be good to add documentation with examples how to deal with different schema registries. Again there are many registries and coupling router with a particular registry isn't a good idea, unless there will be a some Abstract class first, so later community can add implementation


#documentation #enhancement #good_first_issue #confluent #faststream #ag2ai
sent via relator
🚀 New issue to wemake-services/django-modern-rest by @sobolevn
📝 Explain why `openapi_examples_seed` option is not supported per controller and per endpoint (#1436)


Most of our settings can be modified on endpoint and controller levels. But, not this one. Why? Because schemas are generated only globally and can be reused by multiple endpoints and controllers. We need to explain this in the setting docs.


#documentation #good_first_issue #help_wanted #openapi #opensource_september #django_modern_rest
sent via relator
🚀 New issue to wemake-services/django-modern-rest by @sobolevn
📝 Fix docs in the `pyproject.toml` (#1447)


Currently some links and comments are moved due to pyproject-fmt hook, examples:

• django-modern-rest/pyproject.toml

 Line 556 in 87a02f5

• django-modern-rest/pyproject.toml

 Line 408 in 87a02f5

They should be at the top of their sections.

We also need to remove empty sections like:

• django-modern-rest/pyproject.toml

 Line 497 in 87a02f5

This is a very simple issue, please keep it for people who make their first commit :)


#documentation #good_first_issue #help_wanted #opensource_september #django_modern_rest
sent via relator
🚀 New issue to wemake-services/django-modern-rest by @sobolevn
📝 Create pair of JWT tokens for the docs (#1450)


Currently we can't run examples that involve JWT auth, but we have a lot of such examples. So, we need to create a pair of JWT tokens and be able to use them in # run comments the same way we use / run examples with Token auth.

Examples:

• Auth:

 django-modern-rest/docs/examples/auth/token/revoke_token.py

 Lines 11 to 23 in 87a02f5

• django-modern-rest/docs/tools/sphinx_ext/run_examples.py

 Lines 951 to 952 in 87a02f5

Btw, also remove Token support from Query, since we don't use it anymore:

django-modern-rest/docs/tools/sphinx_ext/run_examples.py

Lines 840 to 844 in 87a02f5


#documentation #feature #good_first_issue #help_wanted #opensource_september #django_modern_rest
sent via relator