Находки в опенсорсе: Python
الذهاب إلى القناة على Telegram
Легкие задачки в опенсорсе из мира Python Чат: @opensource_findings_chat
إظهار المزيد1 060
المشتركون
-224 ساعات
-107 أيام
+9630 أيام
أرشيف المشاركات
🚀 New issue to wemake-services/django-modern-rest by @sobolevn
📝 Support explicitly abstract controllers (#1458)
Currently we only infer
Controller.is_abstract ourself:
django-modern-rest/dmr/controller.py
Line 206 in 405ba9b
But, there might be valid cases where people want to define controller to be reused without any customizations or with just the input / return type customizations.
We must respect top-level is_abstract controller definition. Child classes without explicit is_abstract = True must be treated as concrete if they have the serializer.
This way people can create generic controller only on some parts. This would also need a doc update in the "Reusable code" section with the example.
#feature #good_first_issue #help_wanted #opensource_september #django_modern_rest
sent via relator🚀 New issue to wemake-services/django-modern-rest by @sobolevn
📝 Provide concrete views (#1457)
Currently we have a lot of reusable views for auth.
But, this is not really cool to do the manual stuff. Even if it take just several lines. Especially, when I don't need any customizations.
I propose providing new folders near the existing
views/, let's call it concrete_views/ and we will put all the same views with default implementations there.
This way people can just import and use them with no manual work.
This would require a bit of integration testing :)
We would need to test default implementations the same way we test reusable views now.
And we should highlight these new views in the docs. And suggest using them over the more complex reusable ones.
#feature #help_wanted #opensource_september #django_modern_rest
sent via relator🚀 New issue to wemake-services/django-modern-rest by @sobolevn
📝 Pre-compute headers and cookies for `@modify` (#1456)
This is a very important hot-path optimization: currently we build headers and cookies for each response:
django-modern-rest/dmr/validation/response.py
Lines 106 to 110 in 405ba9b
But, as you can see, there's nothing special about each of these calls, they are all the same for the same endpoint. That's why I propose to make this call only once when the endpoint is built in the import time. It would be faster.
#good_first_issue #help_wanted #performance #opensource_september #django_modern_rest
sent via relator
🚀 New issue to wemake-services/django-modern-rest by @sobolevn
📝 Cache the negotiation parts (#1455)
Most of the headers are simple and repeatable. Most users will just send
Content-Type: application/json and Accept: application/json like 99% of the time. So, there's no need to run the negotiation process the second time. We already know the final result. So, go through the https://github.com/wemake-services/django-modern-rest/blob/master/dmr/negotiation.py and find places where we can cache header_value -> parser_class or header_value -> renderer_class computations.
Prefer not to have any API changes here.
#good_first_issue #help_wanted #performance #opensource_september #django_modern_rest
sent via relator🚀 New issue to wemake-services/django-modern-rest by @sobolevn
📝 Improve the performance of `_run_checks` and `_run_async_checks` (#1454)
Currently we have two functions with logic on how to run endpoint checks:
django-modern-rest/dmr/endpoint.py
Lines 417 to 425 in 405ba9b
and then we check inside each call if this call was even needed:
django-modern-rest/dmr/endpoint.py
Lines 427 to 432 in 405ba9b
CALL is not a cheap operation in Python, so I propose a different design.
We should check if the call is needed before the call itself. And only call parts that are actually required.
This is especially important for the async code:
django-modern-rest/dmr/endpoint.py
Lines 460 to 471 in 405ba9b
Where we are awaiting 4 indeprendent coroutines.
We should not, if possible.
#good_first_issue #help_wanted #performance #opensource_september #django_modern_rest
sent via relator🚀 New issue to wemake-services/django-modern-rest by @sobolevn
📝 Support `default` values for `TypeVar` when using controller type var inference (#1452)
We have a
TODO here:
django-modern-rest/dmr/types.py
Lines 318 to 326 in 405ba9b
We either need to:
1. Support the typevars with defaults, add tests, remove TODO
2. Or just add tests and remove TODO if it is already supported
#feature #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🚀 New issue to wemake-services/django-modern-rest by @sobolevn
📝 Increase `DMR_MAX_CACHE_SIZE` to be `1024` (#1448)
django-modern-rest/dmr/envs.py
Line 8 in 87a02f5
I think that we defined a very small default for this value. There can be way more schemes than
256 on a big project. We want to have cache by default on them.
So, use a bigger number :)
#feature #good_first_issue #help_wanted #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
📝 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
📝 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
📝 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
📝 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
📝 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
📝 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
📝 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
📝 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
📝 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/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 ag2ai/faststream by @sobolevn
📝 Consider using `syrupy` for tests (#2978)
Link: https://pypi.org/project/syrupy/
Example usage:
• https://github.com/wemake-services/django-modern-rest/blob/master/tests/test_unit/test_plugins/test_msgspec/test_msgspec_snapshots.py
• https://github.com/wemake-services/django-modern-rest/blob/master/tests/test_unit/test_plugins/test_msgspec/__snapshots__/test_msgspec_snapshots.ambr
#enhancement #good_first_issue #dependencies #faststream #ag2ai
sent via relator
