text stringlengths 185 73.3k | repo stringlengths 7 100 | path stringlengths 4 146 | language stringclasses 7
values | hash stringlengths 16 16 | score float64 7 8.5 | stars int64 0 237k |
|---|---|---|---|---|---|---|
import re
import typing as ty
import pydantic
NTFY_SH_PRIORITIES = ty.Literal[5, 4, 3, 2, 1]
class SearchConfig(pydantic.BaseModel):
"""Configuration of a search"""
name: str
url: str
recursive: bool = True
class FilterConfig(pydantic.BaseModel):
"""Configuration of filters"""
exclude_to... | jonasehrlich/ek-scraper | ek_scraper/config.py | .py | f1cfc3f099f41986 | 7.66 | 20 |
from __future__ import annotations
import logging
import pathlib
import typing as ty
import pydantic
__all__ = ["DataStore", "AdItem"]
_logger = logging.getLogger(__name__)
class AdItem(pydantic.BaseModel):
"""Definition of an Ad item"""
id: str
url: str
title: str
description: str
locati... | jonasehrlich/ek-scraper | ek_scraper/data_store.py | .py | 1f0efdc324098f2c | 7.66 | 20 |
from __future__ import annotations
import asyncio
import collections.abc
import dataclasses
import logging
import typing as ty
from urllib.parse import urljoin
import aiohttp
import bs4
from .config import FilterConfig, SearchConfig
from .data_store import AdItem, DataStore
from .error import UnexpectedHTMLResponse
... | jonasehrlich/ek-scraper | ek_scraper/scraper.py | .py | 24cb7d96495466a9 | 7.66 | 20 |
import importlib
import sys
from collections.abc import Iterator, Sequence
from contextlib import contextmanager
from importlib.abc import Loader, MetaPathFinder
from importlib.machinery import ModuleSpec, PathFinder, SourceFileLoader
from pathlib import Path
from types import ModuleType
from typing import ClassVar
fr... | wenkokke/talondoc | src/talondoc/analysis/static/python/__init__.py | .py | 16dda1f905f59167 | 7.64 | 18 |
import re
from collections.abc import Iterable, Sequence
from dataclasses import dataclass, field
from typing import Optional
import docstring_parser
from .._util.logging import getLogger
_LOGGER = getLogger(__name__)
@dataclass
class InvalidInterpolation(Exception):
"""Exception raised when attempting to inte... | wenkokke/talondoc | src/talondoc/description/__init__.py | .py | c91aeb16dd5cb958 | 7.64 | 18 |
import re
from collections.abc import Iterator, Sequence
from typing import ClassVar, Literal, cast
from docutils import nodes
from sphinx import addnodes
from talonfmt import talonfmt
from tree_sitter_talon import TalonComment
from typing_extensions import final
from ...._util.logging import getLogger
from ....analy... | wenkokke/talondoc | src/talondoc/sphinx/directives/command/abc.py | .py | 4580e9c309241625 | 7.64 | 18 |
from collections.abc import Sequence
from dataclasses import dataclass, field
@dataclass
class AmbiguousSignature(Exception):
"""
Exception raised when multiple objects match the given signature.
"""
location: str
signature: str
candidates: Sequence[str] = field(default_factory=tuple)
de... | wenkokke/talondoc | src/talondoc/sphinx/directives/errors.py | .py | 62928bcb7641195e | 7.64 | 18 |
"""Module containing Enums for Gov.UK colours and ONS Accessible Colours.
Contains:
- GovUKColours: From the GOV.UK colour scheme:
https://design-system.service.gov.uk/styles/colour/
- ONSAccessibleColours: ONS colours taken from the Subnational Indicators Explorer.
"""
from enum import Enum
class GovUKColours(... | communitiesuk/pkg_gov_uk_dashboards | gov_uk_dashboards/colours.py | .py | 8a006033daa3fa0c | 7.48 | 8 |
"""HTML components for displaying messages to the user in a banner format"""
from dash import html
from gov_uk_dashboards.constants import BANNER_STYLE, ERROR_MESSAGE_BANNER_STYLE
def message_banner(category, message, style=None):
"""
Return a coronavirus dashboard-style changelog banner to be used to commu... | communitiesuk/pkg_gov_uk_dashboards | gov_uk_dashboards/components/dash/banners.py | .py | 4cfb69340b18a316 | 7.48 | 8 |
"""data_quality_banner"""
from enum import Enum
from dataclasses import dataclass
from dash import html
from gov_uk_dashboards.components.dash.notification_banner import notification_banner
from gov_uk_dashboards.formatting.text_functions import create_id_from_string
from gov_uk_dashboards.constants import (
NOTIF... | communitiesuk/pkg_gov_uk_dashboards | gov_uk_dashboards/components/dash/data_quality_banner.py | .py | afe757a3c485fa2b | 7.48 | 8 |
"""heading components"""
from enum import Enum
from dash import html
from gov_uk_dashboards.formatting.text_functions import create_id_from_string
class HeadingSizes(str, Enum):
"""Enum class to specify the allowed paragraph sizes"""
EXTRA_LARGE = "govuk-heading-xl"
LARGE = "govuk-heading-l"
MEDIUM... | communitiesuk/pkg_gov_uk_dashboards | gov_uk_dashboards/components/dash/heading.py | .py | 49f356e38fd861b7 | 7.48 | 8 |
"""navbar"""
from typing import Optional
from dash import html
def navbar(links, identifier: Optional[str] = None):
"""A navigation bar for switching between dashboards."""
return html.Nav(
html.Ul(links, className="moj-primary-navigation__list"),
className="moj-primary-navigation",
r... | communitiesuk/pkg_gov_uk_dashboards | gov_uk_dashboards/components/dash/navbar.py | .py | 637f3a157cde39f6 | 7.48 | 8 |
"""paragraph component"""
from enum import Enum
from typing import Union
from dash import html
class ParagraphSizes(str, Enum):
"""Enum class to specify the allowed paragraph sizes"""
LEAD = "govuk-body-l"
DEFAULT = "govuk-body"
SMALL = "govuk-body-s"
def paragraph(
children: Union[str, list]... | communitiesuk/pkg_gov_uk_dashboards | gov_uk_dashboards/components/dash/paragraph.py | .py | 69c457e46580081e | 7.48 | 8 |
"""navbar"""
from typing import Optional
from dash import html, dcc
def side_navbar(
links, identifier: Optional[str] = None, nav_id: str = "navbar-section"
):
"""A navigation bar for switching between dashboards."""
return html.Nav(
html.Ul(
links,
id=identifier if identi... | communitiesuk/pkg_gov_uk_dashboards | gov_uk_dashboards/components/dash/side_navbar.py | .py | a6ea40d0576349b3 | 7.48 | 8 |
"""warning_text"""
from dash import html
def warning_text(text: str, style: dict = None) -> html.Div:
"""
Return Gov UK Design component warning text component, ! with text.
"""
text = html.Div(
format_text(text),
className="govuk-warning-text",
style=style,
)
return t... | communitiesuk/pkg_gov_uk_dashboards | gov_uk_dashboards/components/dash/warning_text.py | .py | 23e21f4c796a9413 | 7.48 | 8 |
import click
from .config import ConnectConfig, InitConfig
from .init import run as run_init
from .tunnel import create as run_connect
@click.group()
def main():
"""
Zenith client entrypoint.
"""
@main.command()
@click.option(
"--config",
"config_path",
type=click.Path(exists=True, file_oka... | azimuth-cloud/zenith | client/zenith/client/cli.py | .py | 58b09727d12ae8c5 | 7.59 | 14 |
import base64
import pathlib
import typing
from configomatic import Configuration, LoggingConfiguration
from pydantic import AnyHttpUrl as PyAnyHttpUrl
from pydantic import (
Field,
FilePath,
TypeAdapter,
ValidationInfo,
conint,
constr,
field_validator,
)
from pydantic.functional_validators... | azimuth-cloud/zenith | client/zenith/client/config.py | .py | 856847517947586b | 7.59 | 14 |
import json
import logging
import subprocess
import sys
import requests
logger = logging.getLogger(__name__)
def ensure_ssh_identity(config):
"""
Ensure that the specified SSH identity exists and return the public key.
"""
if config.ssh_identity_path.exists():
logger.info(f"Using existing SS... | azimuth-cloud/zenith | client/zenith/client/init.py | .py | 905914ce417d1388 | 7.59 | 14 |
import base64
import contextlib
import json
import logging
import os
import re
import signal
import subprocess
import sys
import tempfile
logger = logging.getLogger(__name__)
def get_allocated_port(output):
"""
Extract the allocated port from the output stream.
"""
for line in output:
line = ... | azimuth-cloud/zenith | client/zenith/client/tunnel.py | .py | 981249b8e25329a2 | 7.59 | 14 |
import enum
import typing as t
from configomatic import Configuration as BaseConfiguration
from pydantic import AnyHttpUrl as PyAnyHttpUrl
from pydantic import Field, TypeAdapter, conint, constr
from pydantic.functional_validators import AfterValidator
#: Type for a string that validates as a URL
AnyHttpUrl = t.Annot... | azimuth-cloud/zenith | operator/zenith/operator/config.py | .py | 28c006008ebf234f | 7.59 | 14 |
import asyncio
import base64
import functools
import hashlib
import logging
import sys
import httpx
import kopf
import pydantic
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey
from cryptography.hazmat.primitives.serialization import (
Encoding,
NoEncryption,
PrivateFormat,
... | azimuth-cloud/zenith | operator/zenith/operator/main.py | .py | d1cbeb10eb38020c | 7.59 | 14 |
from kube_custom_resource import CustomResource, schema
from pydantic import Field
class ReservationSpec(schema.BaseModel):
"""
Model for the spec of a reservation.
"""
credential_secret_name: schema.constr(pattern=r"^[a-z0-9-]+$") = Field(
...,
description=(
"The name of ... | azimuth-cloud/zenith | operator/zenith/operator/models/v1alpha1/reservation.py | .py | 25e95da2b455e0ba | 7.59 | 14 |
import json
import jinja2
import yaml
from pydantic.json import pydantic_encoder
from . import models, utils
from .config import settings
def toyaml(obj):
"""
Filter for converting an object to YAML that is able to handle Pydantic models.
"""
# In order to benefit from the Pydantic encoder we need t... | azimuth-cloud/zenith | operator/zenith/operator/template.py | .py | fa0f6c8c26a23f23 | 7.59 | 14 |
import functools
def mergeconcat(defaults, *overrides):
"""
Returns a new dictionary obtained by deep-merging multiple sets of overrides
into defaults, with precedence from right to left.
"""
def mergeconcat2(defaults, overrides):
if isinstance(defaults, dict) and isinstance(overrides, di... | azimuth-cloud/zenith | operator/zenith/operator/utils.py | .py | 2a848e4273f0a878 | 7.59 | 14 |
import base64
import binascii
import contextlib
import hashlib
import hmac
import secrets
import string
from fastapi import FastAPI, HTTPException, Request
from . import backends
from .config import settings
from .models import (
Error,
PublicKeyAssociation,
PublicKeyAssociationRequest,
Reservation,
... | azimuth-cloud/zenith | registrar/zenith/registrar/app.py | .py | 5784dc1cf3037a71 | 7.59 | 14 |
import base64
import httpx
from .. import config # noqa: TID252
from . import base
def fingerprint_urlsafe(fingerprint: bytes) -> str:
return base64.urlsafe_b64encode(fingerprint).decode().rstrip("=")
class Backend(base.Backend):
"""
Registrar backend that stores service information in Consul.
""... | azimuth-cloud/zenith | registrar/zenith/registrar/backends/consul.py | .py | d98be1489e63746d | 7.59 | 14 |
import base64
import logging
from easykube import ApiError, Configuration
from .. import config # noqa: TID252
from . import base
def fingerprint_urlsafe(fingerprint: bytes) -> str:
return base64.urlsafe_b64encode(fingerprint).decode().rstrip("=")
def fingerprint_str(fingerprint: bytes) -> str:
return ba... | azimuth-cloud/zenith | registrar/zenith/registrar/backends/crd.py | .py | 7c5268680c6e098c | 7.59 | 14 |
import enum
from configomatic import Configuration
from pydantic import Field, conbytes, conint, conset, constr
@enum.unique
class SSHPublicKeyType(enum.StrEnum):
"""
Enumeration of the possible SSH public key types.
"""
DSA = "ssh-dss"
RSA = "ssh-rsa"
ECDSA256 = "ecdsa-sha2-nistp256"
EC... | azimuth-cloud/zenith | registrar/zenith/registrar/config.py | .py | c05f919d9ce8ddb8 | 7.59 | 14 |
import logging
import typing as t
import requests
from .. import config # noqa: TID252
from . import base
class Backend(base.Backend):
"""
SSHD backend that stores service information in Consul.
"""
def __init__(
self, logger: logging.Logger, url: str, key_prefix: str, service_tag: str
... | azimuth-cloud/zenith | sshd/zenith/sshd/backends/consul.py | .py | c13440119b102fa6 | 7.59 | 14 |
import logging
import os
import pathlib
import subprocess
import click
import requests
from .config import SSHDConfig
from .tunnel import run as run_tunnel
@click.group()
@click.option(
"--config", type=click.Path(exists=True), help="Path to configuration file"
)
@click.pass_context
def main(ctx, config):
"... | azimuth-cloud/zenith | sshd/zenith/sshd/cli.py | .py | 2d3014dc5eab6e91 | 7.59 | 14 |
import socket
from configomatic import Configuration, LoggingConfiguration
from pydantic import DirectoryPath, Field, FilePath, conint, constr
def default_service_host():
"""
Returns the default service host.
"""
# By default, use the IP address of the host running the script
return socket.gethos... | azimuth-cloud/zenith | sshd/zenith/sshd/config.py | .py | 3600567c9b3bb0fd | 7.59 | 14 |
import base64
import socket
import typing
import warnings
import requests
from cryptography.hazmat.primitives.serialization import load_pem_private_key
from cryptography.x509 import load_pem_x509_certificate
from pydantic import (
AfterValidator,
BaseModel,
Field,
TypeAdapter,
ValidationInfo,
c... | azimuth-cloud/zenith | sshd/zenith/sshd/models.py | .py | 3bc18aba2b25c48d | 7.59 | 14 |
import base64
import contextlib
import json
import logging
import signal
import sys
import time
import warnings
import requests
from . import backends, config, models
class TunnelError(RuntimeError):
"""
Raised when there is an error with the tunnel.
"""
class TunnelExit(RuntimeError): # noqa: N818
... | azimuth-cloud/zenith | sshd/zenith/sshd/tunnel.py | .py | ba39e62db58fbb5a | 7.59 | 14 |
import asyncio
import functools
import typing
from aiohttp import web
if typing.TYPE_CHECKING:
from .processor import Processor
from .store import Store
class Metric:
"""
Base class for metrics.
"""
# The prefix for the metric
prefix = None
# The suffix for the metric
suffix = N... | azimuth-cloud/zenith | sync/zenith/sync/metrics.py | .py | 90f3c289166596c2 | 7.59 | 14 |
# MathCAT add-on: generates speech, braille, and allows exploration of expressions written in MathML
# The goal of this add-on is to replicate/improve on the functionality of MathPlayer which has been discontinued.
# Author: Neil Soiffer
# Copyright: this file uses whatever GNU copyright that is required for NVDA addon... | daisy/MathCATForPython | Example/test.py | .py | 19fa134cd209f593 | 7 | 9 |
# -*- coding: UTF-8 -*-
"""
MathCAT add-on: generates speech, braille, and allows exploration of expressions written in MathML.
The goal of this add-on is to replicate/improve upon the functionality of MathPlayer which has been discontinued.
Author: Neil Soiffer
Copyright: this file is copyright GPL2
The code additi... | daisy/MathCATForPython | addon/globalPlugins/MathCAT/__init__.py | .py | b756ac671d23645f | 7.5 | 9 |
# -*- coding: utf-8 -*-
#!/usr/bin/env python3
import json
import logging
from typing import List
import requests
from . import network
def list_alerts_repo(repository: str, organization: str, token: str) -> List:
"""Get Dependabot alerts for one repository"""
headers = network.get_github_headers(token)
... | Malwarebytes/ghas-cli | src/ghas_cli/utils/dependabot.py | .py | 7dfcda02f014b29d | 7.45 | 7 |
# -*- coding: utf-8 -*-
"""Tests for the repositories module."""
import pytest
from ghas_cli.utils.repositories import Repository
class TestRepository:
"""Tests for the Repository class."""
def test_default_values(self):
"""Test that Repository initializes with correct default values."""
re... | Malwarebytes/ghas-cli | tests/test_repositories.py | .py | 005bfe100e5469de | 7.95 | 7 |
# -*- coding: utf-8 -*-
"""Tests for the template loader module."""
import pytest
from ghas_cli.utils.template_loader import load_template
class TestLoadTemplate:
"""Tests for the load_template function."""
def test_load_codeql_template(self):
"""Test loading the CodeQL markdown template."""
... | Malwarebytes/ghas-cli | tests/test_template_loader.py | .py | 95a071544a66b3d0 | 7.95 | 7 |
# -*- coding: utf-8 -*-
"""Tests for the validation module."""
import pytest
from ghas_cli.utils.validation import (
ValidationError,
validate_branch_name,
validate_organization_name,
validate_repository_name,
)
class TestValidateOrganizationName:
"""Tests for validate_organization_name function... | Malwarebytes/ghas-cli | tests/test_validation.py | .py | ccd7fb3bb81167ab | 7.95 | 7 |
import numpy as np
from numba import njit
from numba.extending import get_cython_function_address
from jax import jit
from jax.scipy.stats.norm import pdf, logpdf
from jax.scipy.stats.multivariate_normal import logpdf as logpdf_mn, pdf as pdf_mn
from jax.scipy.special import logsumexp as logsumexp_jax
import ctypes
@n... | sterinaldi/FIGARO | figaro/_numba_functions.py | .py | 160791aad2cb0ba4 | 7.66 | 20 |
import numpy as np
from figaro.cumulative import fast_log_cumulative
def FindNearest_Volume(ra, dec, dist, value):
"""
Find the pixel that contains the triplet (ra', dec', D') stored in value.
Arguments:
np.ndarray ra: right ascension values used to build the grid
np.ndarray dec: de... | sterinaldi/FIGARO | figaro/credible_regions.py | .py | c888abeece7c9386 | 7.66 | 20 |
import numpy as np
import matplotlib.pyplot as plt
import warnings
from numba import njit, prange
from pathlib import Path
from figaro.exceptions import FIGAROException
from figaro import plot_settings
log2e = np.log2(np.e)
@njit
def angular_coefficient(x, y):
"""
Angular coefficient obtained from linear regr... | sterinaldi/FIGARO | figaro/diagnostic.py | .py | 0b61035ba2ff7189 | 7.66 | 20 |
import numpy as np
from numba import njit
from scipy.special import logsumexp
from figaro.exceptions import FIGAROException
from figaro._likelihood import log_norm
from figaro._numba_functions import inv_jit
from figaro.decorators import probit
@njit
def _cond_mean_cov(vals, mu1, mu2, s11, s22, s12):
"""
Compu... | sterinaldi/FIGARO | figaro/marginal.py | .py | 3dd4640ab6474239 | 7.66 | 20 |
import numpy as np
import warnings
import configparser
import optparse
from pathlib import Path
from collections import Counter
from scipy.stats import multivariate_normal as mn
from figaro._numba_functions import *
from figaro.transform import transform_to_probit, transform_from_probit
def recursive_grid(bounds, n_... | sterinaldi/FIGARO | figaro/utils.py | .py | b99e3898fa2715df | 7.66 | 20 |
import os
import time
from pathlib import Path
def get_template_name(pathfile):
return Path(os.path.relpath(pathfile)).as_posix()
def progress_bar(iterable, prefix='', suffix='', decimals=1, length=100, fill='█', printEnd="\r"):
"""
Call in a loop to create terminal progress bar
@params:
ite... | NextCommerceCo/theme-kit | ntk/utils.py | .py | dc8faf0cc579eef4 | 7.48 | 8 |
import torch
def get_device() -> torch.device:
"""Get the best available device (GPU if available, otherwise CPU)."""
if torch.cuda.is_available():
return torch.device("cuda")
else:
return torch.device("cpu")
def get_gpu_info() -> tuple[list[str], list[int]]:
"""
Get information ... | molinfo-vienna/aweSOM | src/awesom/gpu_utils.py | .py | 0eb49c6af202a308 | 7.54 | 11 |
import torch
from torchmetrics import AUROC, AveragePrecision, F1Score, MatthewsCorrCoef
from torchmetrics.classification import BinaryPrecision, BinaryRecall
THRESHOLD = 0.5
class MetricsCalculator:
"""Simple metrics calculator for site-of-metabolism prediction."""
@staticmethod
def compute_torchmetric... | molinfo-vienna/aweSOM | src/awesom/metrics.py | .py | e95a4a3f4ab8e8e2 | 7.54 | 11 |
import os
from dataclasses import dataclass
import optuna
import torch
import torch.nn.functional as F
from torch import nn
from torch.utils.data import DataLoader
from torch.utils.tensorboard import SummaryWriter
from torch_geometric.data import Data
from torch_geometric.nn import BatchNorm, GINEConv, global_add_pool... | molinfo-vienna/aweSOM | src/awesom/model.py | .py | 88011ee51b03cff0 | 7.54 | 11 |
# Note: initially copied from https://github.com/florimondmanca/httpx-sse/blob/master/src/httpx_sse/_decoders.py
from __future__ import annotations
import json
import inspect
from types import TracebackType
from typing import TYPE_CHECKING, Any, Generic, TypeVar, Iterator, Optional, AsyncIterator, cast
from typing_ext... | knocklabs/knock-python | src/knockapi/_streaming.py | .py | 8eaff1fee18fb958 | 7.62 | 16 |
from __future__ import annotations
from os import PathLike
from typing import (
IO,
TYPE_CHECKING,
Any,
Dict,
List,
Type,
Tuple,
Union,
Mapping,
TypeVar,
Callable,
Iterable,
Iterator,
Optional,
Sequence,
AsyncIterable,
)
from typing_extensions import (
... | knocklabs/knock-python | src/knockapi/_types.py | .py | d36c333473b72fcb | 7.62 | 16 |
from __future__ import annotations
from typing import Any
from typing_extensions import override
from ._proxy import LazyProxy
class ResourcesProxy(LazyProxy[Any]):
"""A proxy for the `knockapi.resources` module.
This is used so that we can lazily import `knockapi.resources` only when
needed *and* so t... | knocklabs/knock-python | src/knockapi/_utils/_resources_proxy.py | .py | 2628305eaf0e73fe | 7.62 | 16 |
from __future__ import annotations
import os
import re
import inspect
import functools
from typing import (
Any,
Tuple,
Mapping,
TypeVar,
Callable,
Iterable,
Sequence,
cast,
overload,
)
from pathlib import Path
from datetime import date, datetime
from typing_extensions import TypeGu... | knocklabs/knock-python | src/knockapi/_utils/_utils.py | .py | da73cecc3acf7b61 | 7.62 | 16 |
#!/usr/bin/env python3
"""Generate formatted GitHub release notes from CHANGELOG.md.
Usage:
python scripts/gen_release_notes.py <version> <repo> [changelog]
Supports optional sections in CHANGELOG.md within a version/Unreleased block:
## [Unreleased]
> One-line description shown below the release title.... | o-murphy/py-aiowialon | .github/actions/gen_release_notes/gen_release_notes.py | .py | b5efde42faac880f | 7.57 | 13 |
"""Async Wialon Remote API client implementation"""
import asyncio
import json
import warnings
from collections.abc import Callable, Coroutine
from contextlib import suppress
from functools import wraps
from typing import Literal
from urllib.parse import urljoin
import aiohttp
from aiolimiter import AsyncLimiter
from... | o-murphy/py-aiowialon | aiowialon/api.py | .py | c3bbec6aa0d4904f | 7.57 | 13 |
import warnings
from abc import ABC
from collections.abc import Coroutine
from typing_extensions import Any, Unpack
from aiowialon import Wialon
from aiowialon.exceptions import WialonWarning
from aiowialon.types.api_types import core
class WialonService(ABC):
def __init__(self, name: str, client: Wialon):
... | o-murphy/py-aiowialon | aiowialon/services/services.py | .py | 41406a0cf62972e9 | 7.57 | 13 |
"""Shortcuts to export/import AVL Items to/from .wlp format"""
from enum import IntEnum
from typing import Any
from aiowialon.api import Wialon
from aiowialon.exceptions import WialonInvalidInput
from aiowialon.types import MultipartField, flags
class WLP:
"""Shortcuts to export/import AVL Items to/from .wlp fo... | o-murphy/py-aiowialon | aiowialon/shortcuts/wlp.py | .py | 905886b573b9855e | 7.57 | 13 |
# pylint: disable=missing-module-docstring,line-too-long,missing-class-docstring
from typing import Any, TypedDict
from aiowialon.utils.compat import StrEnum
class AvlEventType(StrEnum):
"""AVL event types"""
MESSAGE = "m"
UPDATE = "u"
DELETE = "d"
class AvlEventInstance(TypedDict):
i: int
... | o-murphy/py-aiowialon | aiowialon/types/api_types/other.py | .py | 711252b479db0612 | 7.07 | 13 |
"""Object-oriented model for handled AVL-events"""
import asyncio
from collections.abc import Awaitable, Callable
from dataclasses import dataclass, field
from typing import Any
import aiohttp
from aiowialon.exceptions import WialonError
from aiowialon.logger import logger
from aiowialon.types.api_types.other import... | o-murphy/py-aiowialon | aiowialon/types/client_avl_event.py | .py | 475188d09a9caa60 | 7.57 | 13 |
"""Data types for multipart Wialon Remote API calls"""
from dataclasses import asdict, dataclass, field
from typing import Any
@dataclass(frozen=True)
class MultipartField:
"""Dataclas that keeps multipart field data for remote API call"""
name: str
value: Any = field(repr=False)
content_type: str |... | o-murphy/py-aiowialon | aiowialon/types/multipart.py | .py | def9ef68715561c4 | 7.57 | 13 |
"""Async lock for blocking async loop for long critical operations"""
import asyncio
from contextvars import ContextVar
from functools import wraps
from typing import Any
class ExclusiveAsyncLock:
"""
Async lock for blocking async loop for long critical operations.
Callers decorated with `lock` can still... | o-murphy/py-aiowialon | aiowialon/utils/async_lock.py | .py | 10b93fc10121590f | 7.57 | 13 |
"""
Special convention module
to resolve Wialon Remote API specific usage cases with python
"""
from typing import Any
def prepare_action_name(action_name: str) -> str:
"""
Uses for replacing a call 'action_name' with Wialon Remote API 'svc' name
Example:
>>> 'core_search_item' -> 'core/search_item'
... | o-murphy/py-aiowialon | aiowialon/utils/convention.py | .py | b002403edc9fa505 | 7.57 | 13 |
"""Default validator of responses to Wialon Remote API"""
import warnings
from typing import Any
import aiohttp
from aiowialon.exceptions import (
WIALON_EXCEPTIONS,
WialonError,
WialonInvalidResult,
WialonWarning,
)
class WialonCallRespValidator:
"""Validator for responses from Wialon Remote A... | o-murphy/py-aiowialon | aiowialon/validators/call_validator.py | .py | 3481b95d3004ac7b | 7.57 | 13 |
# Copyright (c) 2026 Centre National d'Etudes Spatiales (CNES).
#
# This file is part of Pandora plugin MC-CNN
#
# https://github.com/CNES/Pandora_plugin_mccnn
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a co... | CNES/Pandora_plugin_mccnn | pandora_plugin_mc_cnn/plugin_mc_cnn.py | .py | f747adc2f55d9228 | 7.5 | 9 |
# Copyright (c) 2026 Centre National d'Etudes Spatiales (CNES).
#
# This file is part of Pandora plugin MC-CNN
#
# https://github.com/CNES/Pandora_plugin_mccnn
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a co... | CNES/Pandora_plugin_mccnn | tests/test_check_configuration.py | .py | 7dc7ce404bd5ec0b | 8 | 9 |
# Copyright 2019-2023 SURF.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, soft... | workfloworchestrator/pydantic-forms | pydantic_forms/core/shared.py | .py | ad2b2ccc2c31ae10 | 7.59 | 14 |
# Copyright 2019-2023 SURF.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, soft... | workfloworchestrator/pydantic-forms | pydantic_forms/core/sync.py | .py | 214f537da967ffcd | 7.59 | 14 |
import os
import traceback
from collections.abc import Mapping
from typing import Any, Iterable, Optional, TypedDict, Union, cast
import structlog
from more_itertools import side_effect
from pydantic import ValidationError
from pydantic_core import ErrorDetails
from pydantic_i18n import PydanticI18n
from pydantic_for... | workfloworchestrator/pydantic-forms | pydantic_forms/exceptions.py | .py | 1311876462980134 | 7.59 | 14 |
# Copyright 2019-2025 SURF, ESnet.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writin... | workfloworchestrator/pydantic-forms | pydantic_forms/utils/json.py | .py | 4b58c1535c5421be | 7.59 | 14 |
# Copyright 2019-2025 SURF, ESnet.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writin... | workfloworchestrator/pydantic-forms | pydantic_forms/utils/schema.py | .py | 6584bdfb15173586 | 7.59 | 14 |
# Copyright 2019-2023 SURF.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, soft... | workfloworchestrator/pydantic-forms | pydantic_forms/validators/components/accept.py | .py | d68e8b4b796042cd | 7.59 | 14 |
# Copyright 2019-2025 SURF.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, soft... | workfloworchestrator/pydantic-forms | pydantic_forms/validators/components/callout.py | .py | cd1fb613ef74c7e1 | 7.59 | 14 |
# Copyright 2019-2023 SURF.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, soft... | workfloworchestrator/pydantic-forms | pydantic_forms/validators/components/choice.py | .py | fb56adb1c10002ab | 7.59 | 14 |
# Copyright 2019-2023 SURF.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, soft... | workfloworchestrator/pydantic-forms | pydantic_forms/validators/components/contact_person_list.py | .py | 823755e2572cf5e4 | 7.59 | 14 |
# Copyright 2019-2026 SURF.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, soft... | workfloworchestrator/pydantic-forms | pydantic_forms/validators/components/markdown.py | .py | d113a0f11ca30641 | 7.59 | 14 |
# Copyright 2019-2026 SURF.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, soft... | workfloworchestrator/pydantic-forms | pydantic_forms/validators/components/migration_summary.py | .py | 4542a9bf92236017 | 7.59 | 14 |
# Copyright 2019-2026 SURF, ESnet.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writin... | workfloworchestrator/pydantic-forms | pydantic_forms/validators/components/read_only.py | .py | 1b57b03df4fcb8b0 | 7.59 | 14 |
# Copyright 2019-2023 SURF.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, soft... | workfloworchestrator/pydantic-forms | pydantic_forms/validators/components/unique_constrained_list.py | .py | 9263da42282b7b76 | 7.59 | 14 |
from uuid import uuid4
from pydantic_forms.core import FormPage
from pydantic_forms.validators import DisplaySubscription, Label
from pydantic_forms.validators.components.callout import CalloutMessageType, callout
from tests.unit_tests.helpers import PYDANTIC_VERSION
def test_callout_default():
"""Ensure Callout... | workfloworchestrator/pydantic-forms | tests/unit_tests/test_callout.py | .py | 5ae524a05774c9e5 | 8.09 | 14 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
"""The CLI entrypoint for github-runner-manager application."""
import importlib.metadata
import logging
import signal
import sys
from functools import partial
from io import StringIO
from threading import Lock
from types import FrameType
from ... | canonical/github-runner-operator | github-runner-manager/src/github_runner_manager/cli.py | .py | 69ce899995fef4cf | 7.65 | 19 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
"""Base configuration for the Application."""
import logging
from dataclasses import dataclass
from typing import Optional, TextIO
import yaml
from pydantic import AnyHttpUrl, BaseModel, Field, IPvAnyAddress, root_validator
from github_runner... | canonical/github-runner-operator | github-runner-manager/src/github_runner_manager/configuration/base.py | .py | 8be8169d23c4a0cc | 7.65 | 19 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
"""GitHub API client."""
import functools
import logging
from datetime import datetime
from time import perf_counter
from typing import Any, Callable, ParamSpec, TypeVar
import github
from github import (
BadCredentialsException,
Githu... | canonical/github-runner-operator | github-runner-manager/src/github_runner_manager/github_client.py | .py | a734600b0d7006e2 | 7.65 | 19 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
"""The HTTP server for github-runner-manager."""
import json
from dataclasses import dataclass
from threading import Lock
from flask import Flask, request
from prometheus_client import generate_latest
from github_runner_manager.errors impor... | canonical/github-runner-operator | github-runner-manager/src/github_runner_manager/http_server.py | .py | 403d510db3097c23 | 7.65 | 19 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
"""Module containing the main classes for business logic."""
import secrets
from dataclasses import asdict, dataclass, field
INSTANCE_SUFFIX_LENGTH = 12
class InstanceIDInvalidError(Exception):
"""Raised when the InstanceID naming will b... | canonical/github-runner-operator | github-runner-manager/src/github_runner_manager/manager/models.py | .py | 5d4deb7d301390b9 | 7.65 | 19 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
"""Interface of manager of runner instance on clouds."""
import abc
import logging
from dataclasses import dataclass
from datetime import datetime, timezone
from enum import Enum, auto
from typing import Optional, Protocol, Sequence
from pydan... | canonical/github-runner-operator | github-runner-manager/src/github_runner_manager/manager/vm_manager.py | .py | d8fad380bb17b918 | 7.65 | 19 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
"""Models and functions for the metric events."""
import logging
import os
from pathlib import Path
from typing import Any, Optional
from pydantic import BaseModel, NonNegativeFloat
from github_runner_manager.errors import IssueMetricEventEr... | canonical/github-runner-operator | github-runner-manager/src/github_runner_manager/metrics/events.py | .py | 76c99e66a3fc6dbf | 7.65 | 19 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
"""Module for managing Openstack cloud."""
import logging
from typing import TypedDict, cast
from github_runner_manager.errors import OpenStackInvalidConfigError
logger = logging.getLogger(__name__)
class CloudConfig(TypedDict):
"""The ... | canonical/github-runner-operator | github-runner-manager/src/github_runner_manager/openstack_cloud/__init__.py | .py | 349d6204dba1435e | 7.65 | 19 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
"""Module containing OpenStack Configuration."""
from pydantic import BaseModel
class OpenStackConfiguration(BaseModel):
"""OpenStack configuration.
Attributes:
vm_prefix: Prefix to use for the instances managed by this appli... | canonical/github-runner-operator | github-runner-manager/src/github_runner_manager/openstack_cloud/configuration.py | .py | d05bb3ac02a76b97 | 7.65 | 19 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
"""Module containing OpenStack models."""
from dataclasses import dataclass
from github_runner_manager.configuration import SupportServiceConfig
from github_runner_manager.openstack_cloud.configuration import OpenStackCredentials
@dataclass
... | canonical/github-runner-operator | github-runner-manager/src/github_runner_manager/openstack_cloud/models.py | .py | 0838f12ccfe39c67 | 7.65 | 19 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
"""Manager for self-hosted runner on OpenStack."""
import logging
import secrets
from pathlib import Path
from typing import Sequence
import jinja2
from github_runner_manager.configuration import UserInfo
from github_runner_manager.errors imp... | canonical/github-runner-operator | github-runner-manager/src/github_runner_manager/openstack_cloud/openstack_runner_manager.py | .py | 96834502fa073092 | 7.65 | 19 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
"""Client to interact with the planner service."""
import json
import logging
from dataclasses import dataclass
from typing import Iterable
from urllib.parse import urljoin
import requests
import requests.adapters
import urllib3
from pydantic ... | canonical/github-runner-operator | github-runner-manager/src/github_runner_manager/planner_client.py | .py | bc1ecea8b0532563 | 7.65 | 19 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
"""Client for managing self-hosted runner on GitHub side."""
import concurrent.futures
import logging
from dataclasses import dataclass
from enum import Enum
from pydantic import HttpUrl
from github_runner_manager.configuration.github import ... | canonical/github-runner-operator | github-runner-manager/src/github_runner_manager/platform/github_provider.py | .py | 09e2a8ba7bfc7aeb | 7.65 | 19 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
"""Base classes and APIs for platform providers."""
import abc
from dataclasses import dataclass, field
from datetime import datetime
from enum import Enum, auto
from typing import Sequence
from pydantic import HttpUrl
from github_runner_mana... | canonical/github-runner-operator | github-runner-manager/src/github_runner_manager/platform/platform_provider.py | .py | f2b0e310ce6a41b3 | 7.65 | 19 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
"""Manager for threads."""
import logging
from queue import Queue
from threading import Thread
from typing import Any, Callable
logger = logging.getLogger(__name__)
def _add_err_queue(function: Callable, err_queue: Queue) -> Callable:
""... | canonical/github-runner-operator | github-runner-manager/src/github_runner_manager/thread_manager.py | .py | a31dfcbe03ddba66 | 7.65 | 19 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
"""Module containing GitHub API related types."""
from __future__ import annotations
from datetime import datetime
from enum import Enum
from typing import List, Literal, Optional, TypedDict
from pydantic import BaseModel
from github_runner_... | canonical/github-runner-operator | github-runner-manager/src/github_runner_manager/types_/github.py | .py | 4123d909ace9678a | 7.65 | 19 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
"""Utilities used by the charm."""
import functools
import logging
import os
import subprocess # nosec B404
import time
from typing import Any, Callable, Optional, Sequence, Type, TypeVar
from typing_extensions import ParamSpec
logger = logg... | canonical/github-runner-operator | github-runner-manager/src/github_runner_manager/utilities.py | .py | bce6a57eca73e9f4 | 7.65 | 19 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
"""Test infrastructure for managing running application instances."""
import logging
import multiprocessing
import os
import time
from dataclasses import dataclass
from pathlib import Path
from typing import Any
import requests
import yaml
fr... | canonical/github-runner-operator | github-runner-manager/tests/integration/application.py | .py | b50c926a4039f608 | 8.15 | 19 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
"""Fixtures for github-runner-manager integration tests."""
import logging
import os
import time
from pathlib import Path
from typing import Generator, cast
import openstack
import pytest
from github import Github
from github.Auth import Token... | canonical/github-runner-operator | github-runner-manager/tests/integration/conftest.py | .py | 1596c5e19d8a2686 | 8.15 | 19 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
"""Factory functions for creating test data and configurations."""
import secrets
import string
from dataclasses import asdict, dataclass, field
from pathlib import Path
from typing import Any
# Single source of truth for resource names create... | canonical/github-runner-operator | github-runner-manager/tests/integration/factories.py | .py | aab680ab0f11e218 | 8.15 | 19 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
"""Helper functions for GitHub integration testing."""
import logging
from datetime import datetime, timezone
from time import sleep, time
import requests
from github.Branch import Branch
from github.GithubException import GithubException
from... | canonical/github-runner-operator | github-runner-manager/tests/integration/github_helpers.py | .py | 040542f65a8c7e17 | 8.15 | 19 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.