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

Чат: @opensource_findings_chat
Download Telegram
🚀 New issue to wemake-services/django-modern-rest by @sobolevn
📝 Change how `attrs` extra is defined (#1342)


django-modern-rest/pyproject.toml

Lines 69 to 70 in a2d44b1

Currently we define msgspec twice, but we should replace the second entry with django-modern-rest[msgspec]
(please, do not take this issue before the 1st of September)


#feature #good_first_issue #help_wanted #dependencies #pythonuv #opensource_september #django_modern_rest
sent via relator
🚀 New issue to wemake-services/django-modern-rest by @vyhuholl
📝 `JWToken.encode` raises `InternalServerError`, an HTTP-layer exception (#1364)



#bug #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/wemake-python-styleguide by @Novohudonossor
📝 tstring_same_prefix params contain f-strings — the t-string coverage from #3702 is never exercised (#3793)


What's wrong

Two test constants touched by #3702 ("extend f-string rules to t-strings") do not exercise t-strings at all.

1. tests/test_visitors/test_ast/test_complexity/test_overuses/test_overused_string.py:112-131

tstring_same_prefix1 = pytest.param(
"""
x = f'Hello, {pattern}'
y = f'Hello, {pattern}'
""",
marks=pytest.mark.skipif(not PY314, reason='t-strings are only in Python 3.14+'),
)

The snippet is identical to fstring_same_prefix1 right above it. Below 3.14 the param is skipped by the mark; on 3.14+ it runs and asserts on f-strings. Either way WPS226 is never checked against a t-string, and the suite stays green.

2. tests/test_visitors/test_tokenize/test_comments/test_comment_in_formatted_string312.py:87

PREFIXES is ['f', 't'] and both tests run code.format(prefix), so every constant is exercised twice. rfstring_with_comment_triple_single_quotes hardcodes rf'''…''' instead of r{0}'''…''' like its two siblings above it, so the t round re-tests rf.

How it should be
1. t'Hello, {pattern}' and t'{pattern}-postfix' inside the two tstring_same_prefix* params.
2. r{0}'''test{{a # comment\n}}''', matching rfstring_with_comment_single_quotes and rfstring_with_comment_triple_quotes.

Happy to open a PR for both if that is useful.

Flake8 version and plugins / pip information / OS information

Not applicable — this is not a runtime report. Found by reading the tests, verified against HEAD 8ebc607; there is no flake8 --bug-report output to paste.

Provenance

Both came out of a review run with ReviewGate (https://reviewgate.dev), a local review gate I build, over 76b3ac3~1..c580fc3. The run was local, on my own model key, and nothing left my machine.


#bug #help_wanted #levelstarter #good_first_issue #wemake_python_styleguide #wps
sent via relator
🚀 New issue to wemake-services/django-modern-rest by @sobolevn
📝 Provide faster JWT decode and encode options with `msgspec` (#1390)


When msgspec is installed, we can speed up the pyjwt encode and decode.

By default it uses the default json module for both convertions:

1. https://github.com/jpadilla/pyjwt/blob/7144e4534c34810f4525dc4578a32addd8212cff/jwt/api_jwt.py#L156-L172
2. https://github.com/jpadilla/pyjwt/blob/7144e4534c34810f4525dc4578a32addd8212cff/jwt/api_jwt.py#L287-L301

We can provide our own PyJWT subclass and make the process faster. Since JWT is a hot path, even a smaller boost will be a massive win overall.

This will require a benchmark test :)


#feature #good_first_issue #help_wanted #security #opensource_september #django_modern_rest
sent via relator
🚀 New issue to wemake-services/django-modern-rest by @sobolevn
📝 Cache OpenAPI views schema generation (#1398)


Currently, our OpenAPI views are really slow, because they recompute the schema on each request. Which is a bad thing if this schema is publicly available and has a lot of traffic.

Example:

django-modern-rest/dmr/openapi/views/json.py

Lines 28 to 30 in 06626f9

Proposal: we need to cache the schema generation. Not the view itself, because it can be cached by the user via a decorator. This might go to the docs as an example.

@cachedproperty seems like the best solution here.


#feature #good_first_issue #help_wanted #openapi #opensource_september #django_modern_rest
sent via relator
🚀 New issue to wemake-services/django-modern-rest by @sobolevn
📝 Rename `json_dump` to `json_dumps` (#1399)


json.dump works with files, while json.dumps works with strings, which is the case here:

django-modern-rest/dmr/internal/json.py

Lines 109 to 120 in 06626f9

We need to rename our helpers from json_dump to json_dumps and list this as a breaking change.


#bug #good_first_issue #help_wanted #opensource_september #django_modern_rest
sent via relator
1
🚀 New issue to faststream-community/zMQTT by @borisalekseev
📝 MQTT 5: expose structured metadata from broker DISCONNECT packets (#89)


Problem

In zmqtt 0.2.1, a broker DISCONNECT becomes a generic MQTTDisconnectedError containing the reason code only in its message text. Decoded Reason String, User Properties, and Server Reference are discarded. Applications cannot reliably inspect why the broker closed the connection.

The relevant paths are _dispatch(), DisconnectProperties, and MQTTDisconnectedError.

Expected behavior

Implement support for MQTT 5 §3.14, DISCONNECT:

• Expose the broker's reason_code, Reason String, User Properties, and Server Reference as structured public data.
• Make the event observable even when automatic reconnect subsequently succeeds.
• Preserve these details when a broker disconnect is propagated to affected callers.
• Distinguish a broker DISCONNECT from a transport failure where no MQTT reason code was received.
• Keep duplicate User Property keys and avoid requiring applications to parse exception text.

Related: #85 exposes the corresponding CONNACK metadata. Following Server Reference is a separate feature.


#good_first_issue #opensource_september #faststream #zmqtt
sent via relator
🚀 New issue to wemake-services/wemake-python-styleguide by @sobolevn
📝 Do not count docstrings for `WPS226` (#3803)


dmr/security/jwt/views.py

155:9 WPS226 Found string literal over-use: 'Lazy endpoint spec.' 6 > 3
"""Lazy endpoint spec."""
^

I just got this, where """Lazy endpoint spec.""" is an actual docstring.
This is not right.


#bug #help_wanted #levelstarter #good_first_issue #wemake_python_styleguide #wps
sent via relator
🚀 New issue to wemake-services/django-modern-rest by @sobolevn
📝 Add controller-level `tags` (#1434)


For some reason we don't have tags that can be defined for all endpoints in the controller. We only have per-endpoint and per-router:

django-modern-rest/dmr/endpoint.py

Lines 288 to 292 in 87a02f5

So, let's add controller level tags support as well.


#feature #good_first_issue #help_wanted #openapi #opensource_september #django_modern_rest
sent via relator
🚀 New issue to wemake-services/django-modern-rest by @sobolevn
📝 Remove OpenAPI 3.0.x support (#1435)


We claimed that we supported OpenAPI 3.0.x, but this was never the case, we always supported a subset of 3.0.x, because only 3.1 started supporting JsonSchema that we use for our models.

We need to remove the support from both docs and code.


#bug #good_first_issue #help_wanted #openapi #opensource_september #django_modern_rest
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
📝 Make sure all `bool` values in `dmr.openapi.objects` can also accept `None` (#1437)


Why is this important? Because we ignore None values from the schema dump. But, now all deprecated: False objects are dumped. This is the default, no need to do this.

We need to:

• Update bool = False to be bool | None = None
• Update all snapshots to remove exising values

All Nones will be ignored.


#feature #good_first_issue #help_wanted #openapi #opensource_september #django_modern_rest
sent via relator
🚀 New issue to wemake-services/django-modern-rest by @sobolevn
📝 Improve `re_path` default parameter schema (#1439)


Currently we default to str as schema for all patterns in re_path. However, this is not the only thing we can do. We can also copy the pattern itself to the schema. Example:

re_path(r'^v(?P<version>\d+)/$', VersionController.as_view())  # schema: {type: string}

We can copy the pattern as well:

# re_path (?P<version>\d+)
- name: version
in: path
schema: {type: string, pattern: '^\d+$'}

This way users would have more info about what is expected.
See

django-modern-rest/dmr/openapi/generators/component_parsers.py

Lines 136 to 152 in 87a02f5

for current schema generation.


#feature #good_first_issue #help_wanted #openapi #opensource_september #django_modern_rest
sent via relator
🚀 New issue to wemake-services/django-modern-rest by @sobolevn
📝 Improve path customization tests, `__dmr_converter_schema__` is never tested (#1440)


Currently we claim to support __dmr_converter_schema__ attribute to customize how Django path converters generate schema, but we never actually test it.

See

django-modern-rest/dmr/openapi/generators/component_parsers.py

Lines 117 to 123 in 87a02f5

We need at least two tests:

• Valid customization
• Invalid one that will fail the final schema validation

#bug #good_first_issue #help_wanted #opensource_september #django_modern_rest
sent via relator
🚀 New issue to wemake-services/django-modern-rest by @sobolevn
📝 Support `SlugConverter` and `PathConverter` from Django in path parameters (#1441)


Currently we only support int and uuid converters from django:

django-modern-rest/dmr/openapi/generators/component_parsers.py

Lines 36 to 41 in 87a02f5

However, there are two more that we can support:

path, we can add {"description": "Can contain slashes"} to the schema
slug, we can add the pattern from SlugConverter

This needs to be tested. Probably we can also change the storage API. I am not sure how currently represent in for all possible providers. Probably we can store prepared schemas for types that exist.


#feature #good_first_issue #help_wanted #openapi #opensource_september #django_modern_rest
sent via relator
🚀 New issue to wemake-services/django-modern-rest by @sobolevn
📝 Ensure that you can include abstract controllers in `Router` (#1445)


Currently Router will say nothing if you try to include Controller with is_abstract == True into the url patterns.

I propose changing as_view logic here:

django-modern-rest/dmr/controller.py

Lines 209 to 223 in 87a02f5

.as_view() must be impossible to call on the abstract controller.
Raise EndpointMetadataError for this case.


#feature #good_first_issue #help_wanted #opensource_september #django_modern_rest
sent via relator
🚀 New issue to wemake-services/django-modern-rest by @sobolevn
📝 Parse `summary` and `description` from `Controller` for `PathItem` docs (#1446)


Currently we don't parse summary and description from docstrings for controllers, only for endpoints. This is not good.

django-modern-rest/dmr/controller.py

Lines 553 to 561 in 87a02f5

What we can do instead?

• Use Empty as the default value for Controller.summary and Controller.description
• If it is empty, parse summary and description from the docstring, just like EndpointMetadata does
• If it is explicitly None, then do nothing
• Test this
• Update all existing snapshots

#feature #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