Skip to content

Instantly share code, notes, and snippets.

@Bahus
Bahus / tasks.py
Last active August 1, 2022 15:19 — forked from mihalt/tasks.py
planning of architecture
from decimal import Decimal
import pydantic
@shared_task
def get_provider_api_stocks(api_key, url_constructor, deserialize_constructor):
# api_key в принципе нельзя передавать так
return True
[tool.flakehell.plugins]
pycodestyle = [
"+*",
"-W503", # line break before binary operator
]
"flake8-docstrings" = ["-*"]
"flake8-*" = [
"+*",
"-S311", # Using random for cryptographic purposes
"-S101", # Assert detected
from http import HTTPStatus
import pytest
def browser_client(request):
user_name = request.param
credentials = get_credentials_for_user(user_name)
client = Client()
client.login(**credentials)
client.user = user_name
@Bahus
Bahus / json_schemed_field.py
Last active September 19, 2024 23:53
Django JSONField with Pydantic schema support
from functools import partial
import pydantic
import logging
from django.contrib.postgres.fields import JSONField
from typing import Type, Union, Tuple
from django.core.serializers.json import DjangoJSONEncoder
# -*- coding: utf-8 -*-
from ansible.callbacks import display
from pprint import pformat
class FilterModule(object):
def filters(self):
return {
'shell_printer': self.shell_printer,
@Bahus
Bahus / gunicorn
Created August 26, 2012 21:29 — forked from suda/gunicorn
Gunicorn init.d script (debian/ubuntu)
#!/bin/sh
### BEGIN INIT INFO
# Provides: gunicorn
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the gunicorn server
# Description: starts gunicorn using start-stop-daemon