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
import functools | |
from typing import Callable, Any | |
from loguru import logger | |
from integration.utils import retry | |
def run_something(f: Callable, *args: Any, **kwargs: Any) -> None: | |
try: |
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
import sys | |
import paramiko | |
def main(hosts: list[str]) -> None: | |
for host in hosts: | |
transport = paramiko.transport.Transport((host, 22)) | |
transport.start_client(timeout=1) | |
key = transport.get_remote_server_key() |
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
""" | |
MIT License | |
Copyright (c) 2018 Mitchel Cabuloy | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is |
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
""" | |
Implement the conversion of the dotted version string to an integer and reverse conversion. | |
This approach can be used to compactly store large amounts of version data. | |
""" | |
import struct | |
from typing import List, Optional | |
import pytest |
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
import enum | |
from typing import Iterable, Type | |
def merge_enums(new_name: str, *enums: Iterable[Type[enum.Enum]]) -> Type[enum.Enum]: | |
attributes = [{m.name: m.value for m in e} for e in enums] | |
intersection = set.intersection(*map(set, attributes)) | |
if intersection: | |
raise ValueError(f"Error codes are duplicated: {', '.join(intersection)}") |
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
import sys | |
import contextlib | |
from pathlib import Path | |
from typing import Any, ClassVar, Dict, Iterable, List, Optional | |
import requests | |
class GameApi: | |
base_url: ClassVar[str] = 'https://www.planitpoker.com/api/' |
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 contextlib import contextmanager | |
from typing import TYPE_CHECKING, Any, Iterator | |
from my_app.settings import get_settings | |
if TYPE_CHECKING: | |
from my_app.settings import Settings | |
@contextmanager |
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
# tests/helpers.py | |
from contextlib import contextmanager | |
from typing import TYPE_CHECKING, Any, Iterator | |
from defmain.settings import get_settings | |
if TYPE_CHECKING: | |
from defmain.settings import Settings |
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
# shellcheck disable=SC2046 | |
docker build -f docker/Dockerfile -t defmain/backend:latest . -t defmain/backend:$(git rev-parse --short HEAD) |
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 graphene import InputObjectType, ObjectType, Schema, String, ID, Field, List | |
class UserSchema(ObjectType): | |
username = String() | |
first_name = String() | |
class PostSchema(ObjectType): | |
id = ID() |
NewerOlder