Skip to content

Instantly share code, notes, and snippets.

View jacek-jablonski's full-sized avatar

Jacek Jabłoński jacek-jablonski

View GitHub Profile
from collections.abc import Callable, Collection
from typing import ParamSpec, TypeVar
R = TypeVar("R")
P = ParamSpec("P")
def disable(
func_or_metrics: Collection[int] | Callable[P, R]
) -> Callable[[Callable[P, R]], Callable[P, R]] | Callable[P, R]:
@jacek-jablonski
jacek-jablonski / pyproject.toml
Created December 5, 2022 12:58
pyproject.torml
[tool.poetry]
name = "app"
version = "0.1.0"
description = ""
authors = ["App Author <[email protected]>"]
packages = [{ include = "app", from = "." }]
[[tool.poetry.source]]
name = "custom-python"
# file: app.py
from flask import Flask
from redis_instance import create_redis
def create_app(script_info: ScriptInfo = None):
app = Flask('myapp')
with app.app_context():
from flask import g
g.redis = create_redis()
return app
>>> from flask import Flask
>>> from flask import g
>>> app=Flask('test')
>>> with app.app_context():
... g.e='test'
...
>>> with app.app_context():
... print(g.e)
...
Traceback (most recent call last):