This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
########################################################################################################## | |
# I've used this pre-commit hook in my FastAPI app. It launches `bash` session (even on Windows) from the root dir of your project. | |
# Meaning if you have a following project structure: | |
############################### | |
# app/ # | |
# .git # | |
# __pycache__ # | |
# .mypy_cache # | |
# config/ # |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def transform_to_datetime(date_string: str) -> datetime: | |
"""Normalises different datetimes and turns them into `datetime` | |
objects. | |
Needed in case time output from the site changes in the future. | |
Parameters | |
---------- | |
date_string : str | |
Datetime presented in `str` format. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[tool.mypy] | |
strict = true | |
[tool.isort] # pyproject.toml, .isort.cfg = [settings] | |
profile = "black" | |
multi_line_output = 3 | |
lines_after_imports = 2 | |
lines_between_sections = 0 # novk | |
force_alphabetical_sort_within_sections = true # vk | |
include_trailing_comma = true # vk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__pycache__ | |
.venv | |
.vscode | |
.mypy_cache | |
.pytest_cache | |
.dockerignore | |
*.ps1 | |
*.sh | |
*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias black79="black --line-length 79 --force-exclude '((^.*(\/migrations\/).*\.py)|(.*\.(?!pyi?$)[^.]+$))' --extend-exclude migrations/" | |
alias isort79="isort --multi-line 3 --force-alphabetical-sort-within-sections --trailing-comma --combine-as --lines-after-imports 2 --filter-files --extend-skip migrations" | |
alias autoflake79="autoflake --remove-all-unused-imports --ignore-init-module-imports -r -v --in-place --exclude '*/migrations/*'" | |
git diff --quiet --cached --name-only --diff-filter=D | |
start_condition_0=$? | |
git diff --quiet --cached --name-only --diff-filter=ACMR | |
start_condition_1=$? | |
if [ $start_condition_0 = 0 ] && [ $start_condition_1 = 1 ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.git/info/exclude is a local .gitignore file. Same syntax as .gitignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pip freeze | sed 's/=.*//g' | xargs pip uninstall -y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections.abc import Iterable, Sequence | |
from typing import TypeVar, TypedDict | |
import xlsxwriter | |
from .items import Item | |
T = TypeVar("T") | |
class Data(TypedDict): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import annotations | |
from typing import Callable, Union | |
class Pipe: | |
def __init__(self, callable_: Callable): | |
self.callable_ = callable_ | |
def __rshift__(self, then: Callable | Pipe) -> Pipe: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
command 2>&1 >/dev/null | grep "line" |
OlderNewer