repo
stringclasses
454 values
file_path
stringlengths
5
201
extension
stringclasses
1 value
content
stringlengths
8
509k
num_lines
int64
3
16.9k
size_bytes
int64
8
511k
flit
tests/test_tomlify.py
.py
from pathlib import Path try: import tomllib except ImportError: import tomli as tomllib from testpath import assert_isfile from flit import tomlify samples_dir = Path(__file__).parent / 'samples' def test_tomlify(copy_sample, monkeypatch): td = copy_sample('with_flit_ini') monkeypatch.chdir(td) ...
31
754
wandb
wandb/sdk/artifacts/_generated/rename_registry.py
.py
# Generated by ariadne-codegen # Source: tools/graphql_codegen/artifacts/ from __future__ import annotations from pydantic import Field from wandb._pydantic import GQLResult from .fragments import RegistryFragment class RenameRegistry(GQLResult): rename_project: RenameRegistryRenameProject | None = Field(alia...
24
527
confluent-kafka-python
src/confluent_kafka/kafkatest/verifiable_consumer.py
.py
#!/usr/bin/env python # # Copyright 2016 Confluent Inc. # # 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...
343
12,415
textual
tests/option_list/test_option_prompt_replacement.py
.py
"""Test replacing options prompt from an option list.""" import pytest from textual.app import App, ComposeResult from textual.widgets import OptionList from textual.widgets.option_list import Option, OptionDoesNotExist class OptionListApp(App[None]): """Test option list application.""" def compose(self) ->...
73
3,245
clearml
clearml/backend_config/converters.py
.py
import base64 from typing import Union, Optional, Any, TypeVar, Callable, Tuple ConverterType = TypeVar("ConverterType", bound=Callable[[Any], Any]) def strtobool(val: str) -> int: """Convert a string representation of truth to true (1) or false (0). True values are 'y', 'yes', 't', 'true', 'on', and '1'; f...
63
1,847
ipython
tests/tclass.py
.py
"""Simple script to be run *twice*, to check reference counting bugs. See test_run for details.""" import sys # We want to ensure that while objects remain available for immediate access, # objects from *previous* runs of the same script get collected, to avoid # accumulating massive amounts of old references. clas...
36
920
wandb
tests/unit_tests/test_filters/test_filters.py
.py
from __future__ import annotations import json from typing import Any from hypothesis import given from hypothesis.strategies import booleans, builds, integers, lists, sampled_from from wandb._filters import ( All, And, Contains, Eq, Exists, FilterExpr, Gt, Gte, In, Lt, Lte...
403
12,262
probability
tensorflow_probability/python/internal/backend/numpy/__internal__.py
.py
# pylint: disable=invalid-name # Copyright 2021 The TensorFlow Probability Authors. # # 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 # # Unle...
25
917
saleor
saleor/tests/e2e/checkout/test_buy_gift_card_in_the_checkout.py
.py
import pytest from ..account.utils import get_own_data from ..gift_cards.utils import get_gift_cards from ..orders.utils import order_query from ..product.utils import ( create_category, create_product, create_product_channel_listing, create_product_type, create_product_variant, create_product_...
166
4,539
pyomo
pyomo/contrib/cp/tests/test_sequence_var.py
.py
# ____________________________________________________________________________________ # # Pyomo: Python Optimization Modeling Objects # Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC # Under the terms of Contract DE-NA0003525 with National Technology and Engineering # Solutions of...
157
5,230
confluent-kafka-python
tests/test_kafka_error.py
.py
#!/usr/bin/env python import time import pytest from confluent_kafka import KafkaError, KafkaException, Producer seen_all_brokers_down = False def error_cb(err): print('error_cb', err) assert err.fatal() is False if err.code() == KafkaError._ALL_BROKERS_DOWN: global seen_all_brokers_down ...
116
3,321
hydra
plugins/hydra_optuna_sweeper/hydra_plugins/hydra_optuna_sweeper/_impl.py
.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import functools import logging import sys from typing import ( Any, Callable, Dict, List, MutableSequence, Optional, Sequence, Tuple, ) import optuna from hydra.core.override_parser.overrides_parser import Overrides...
387
14,739
jupyterlab
jupyterlab/extensions/pypi.py
.py
# Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. """Extension manager using pip as package manager and PyPi.org as packages source.""" import asyncio import http.client import io import json import math import re import sys import tempfile import xmlrpc.client from ...
719
27,560
coremltools
coremltools/converters/mil/frontend/torch/internal_graph.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause from collections import OrderedDict, deque from typing import Any, Dict, List, Optional, Tuple, Union...
713
27,856
mlflow
tests/telemetry/test_tracked_events.py
.py
import json import time from unittest import mock from unittest.mock import AsyncMock, MagicMock, patch import pandas as pd import pytest import sklearn.neighbors as knn from click.testing import CliRunner from fastapi import Request import mlflow from mlflow import MlflowClient from mlflow.entities import ( Eval...
2,655
84,225
openvino
tests/layer_tests/tensorflow_tests/test_tf_GRUBlockCell.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import numpy as np import pytest import tensorflow as tf from common.tf_layer_test_class import CommonTFLayerTest rng = np.random.default_rng(2024) class TestGRUBlockCell(CommonTFLayerTest): def _prepare_input(self, inputs_info): ...
62
2,488
pyro
examples/vae/utils/vae_plots.py
.py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 import torch def plot_conditional_samples_ssvae(ssvae, visdom_session): """ This is a method to do conditional sampling in visdom """ vis = visdom_session ys = {} for i in range(10): ys[i] = torch....
123
3,678
httpie
httpie/cli/requestitems.py
.py
import os import functools from typing import Callable, Dict, IO, List, Optional, Tuple, Union from .argtypes import KeyValueArg from .constants import ( SEPARATORS_GROUP_MULTIPART, SEPARATOR_DATA_EMBED_FILE_CONTENTS, SEPARATOR_DATA_EMBED_RAW_JSON_FILE, SEPARATOR_GROUP_NESTED_JSON_ITEMS, SEPARATOR_DATA_RAW...
231
7,546
mlflow
dev/clint/tests/rules/test_mock_patch_as_decorator.py
.py
from pathlib import Path from clint.config import Config from clint.index import SymbolIndex from clint.linter import Position, Range, lint_file from clint.rules.mock_patch_as_decorator import MockPatchAsDecorator def test_mock_patch_as_decorator_unittest_mock(index: SymbolIndex) -> None: code = """ import unitt...
110
3,387
wagtail
wagtail/admin/userbar.py
.py
from warnings import warn from django.forms import Media from django.utils import translation from django.utils.translation import gettext_lazy as _ from wagtail import hooks from wagtail.admin.ui.components import Component from wagtail.admin.utils import get_admin_base_url from wagtail.models import Revision from w...
415
15,507
wandb
wandb/apis/public/registries/__init__.py
.py
__all__ = [ "Registry", # doc:exclude "Registries", # doc:exclude ] from .registries_search import Registries from .registry import Registry
8
152
onnxruntime
onnxruntime/python/tools/transformers/fusion_gemmfastgelu.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- from logging import getLogger from fusion_base import Fusion from fusi...
122
4,087
pyro
examples/vae/vae_comparison.py
.py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 import argparse import itertools import os from abc import ABCMeta, abstractmethod import torch import torch.nn as nn from torch.nn import functional from torchvision.utils import save_image from utils.mnist_cached import DATA_DIR...
276
9,094
mlflow
mlflow/strands/autolog.py
.py
import json import logging import threading from opentelemetry.context import Context from opentelemetry.sdk.trace import ( ReadableSpan as OTelReadableSpan, ) from opentelemetry.sdk.trace import ( Span as OTelSpan, ) from opentelemetry.sdk.trace import ( TracerProvider as SDKTracerProvider, ) from opentel...
180
7,137
readthedocs.org
readthedocs/projects/tasks/storage.py
.py
from enum import StrEnum from enum import auto import structlog from django.core.files.storage import storages from readthedocs.doc_builder.exceptions import BuildAppError log = structlog.get_logger(__name__) class StorageType(StrEnum): build_media = auto() build_tools = auto() def get_storage(*, build_...
101
3,158
cvxpy
cvxpy/tests/nlp_tests/test_affine_atoms.py
.py
""" Copyright, the CVXPY authors 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, software ...
169
5,867
clearml
clearml/storage/filepaths.py
.py
import os from itertools import takewhile from typing import Optional, Union, Sequence from pathlib import Path def get_common_path(filepaths: Sequence[Union[str, Path]]) -> Optional[str]: """ Return the common path of a list of file paths :param filepaths: list of files (str or Path objects) :retur...
73
2,724
saleor
saleor/core/auth_backend.py
.py
import jwt from django.conf import settings from ..account.models import User from ..graphql.account.dataloaders import UserByEmailLoader from ..graphql.plugins.dataloaders import AnonymousPluginManagerLoader from ..graphql.site.dataloaders import get_site_promise from ..permission.enums import ( get_permissions_f...
190
7,546
beam
sdks/python/apache_beam/examples/avro_nyc_trips_test.py
.py
# # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not us...
152
4,908
openvino
tests/e2e_tests/common/table_utils.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 """Common table formatting/creation utils used across E2E tests framework.""" #pylint:disable=import-error from tabulate import tabulate def make_table(*args, **kwargs): """Wrapper function for `tabulate` to unify table styles acro...
14
455
onnx
onnx/reference/ops/op_softmax_cross_entropy_loss.py
.py
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import numpy as np from onnx.reference.op_run import OpRun def softmaxcrossentropy( x, target, weight=None, reduction="mean", ignore_index=None, get_log_prob=None ): input_shape = x.shape ...
95
2,950
openvino
src/frontends/paddle/tests/test_models/gen_scripts/generate_group_norm.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 # # group norm paddle model generator # import numpy as np from save_model import saveModel import paddle import sys data_type = "float32" def group_norm(name: str, x, groups, epsilon, scale, bias, data_layout): paddle.enable_stati...
71
2,298
mamba
releaser.py
.py
# Script to release any of the mamba packages. # This script has no cli parameters and only read info from the root changelog # which must have been modified by executing `update_changelog.py`. # Please refer to `update_changelog.py` for more info about the release process. import copy import datetime import re from v...
210
6,857
sqlmap
tests/test_nosql.py
.py
#!/usr/bin/env python """ Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org) See the file 'LICENSE' for copying permission Offline, deterministic tests for the NoSQL injection engine. Mock oracles stand in for the HTTP/back-end layer so detection and blind extraction can be exercised without a live target...
958
43,579
astropy
astropy/units/tests/test_quantity_info.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """Test the propagation of info on Quantity during operations.""" import copy import numpy as np import pytest from astropy import units as u def assert_info_equal(a, b, ignore=set()): a_info = a.info b_info = b.info for attr in (a_info.at...
180
5,092
metrics
src/torchmetrics/image/perceptual_path_length.py
.py
# Copyright The Lightning team. # # 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...
183
8,523
metrics
_samples/plotting.py
.py
# Copyright The Lightning team. # # 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...
457
13,033
mlflow
mlflow/evaluation/__init__.py
.py
""" THE 'mlflow.evaluation` MODULE IS LEGACY AND WILL BE REMOVED SOON. PLEASE DO NOT USE THESE CLASSES IN NEW CODE. INSTEAD, USE `mlflow/entities/assessment.py` FOR ASSESSMENT CLASSES. """ from mlflow.evaluation.assessment import Assessment, AssessmentSource, AssessmentSourceType from mlflow.evaluation.evaluation impo...
17
513
mlflow
mlflow/store/_unity_catalog/lineage/constants.py
.py
_DATABRICKS_ORG_ID_HEADER = "x-databricks-org-id" _DATABRICKS_LINEAGE_ID_HEADER = "X-Databricks-Lineage-Identifier"
3
116
pyomo
examples/performance/misc/bilinear1_100.py
.py
# ____________________________________________________________________________________ # # Pyomo: Python Optimization Modeling Objects # Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC # Under the terms of Contract DE-NA0003525 with National Technology and Engineering # Solutions of...
31
1,001
coremltools
coremltools/converters/mil/experimental/__init__.py
.py
# Copyright (c) 2021, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
5
218
sphinx
tests/test_extensions/test_ext_coverage.py
.py
"""Test the coverage builder.""" from __future__ import annotations import pickle from typing import TYPE_CHECKING import pytest if TYPE_CHECKING: from sphinx.testing.util import SphinxTestApp @pytest.mark.sphinx('coverage', testroot='root') def test_build(app: SphinxTestApp) -> None: app.build(force_all=...
132
4,252
biopython
Bio/Data/IUPACData.py
.py
# Copyright 2000 Andrew Dalke. All rights reserved. # # This file is part of the Biopython distribution and governed by your # choice of the "Biopython License Agreement" or the "BSD 3-Clause License". # Please see the LICENSE file that should have been included as part of this # package. """Information about the IUPA...
421
9,223
omegaconf
tests/structured_conf/data/attr_classes.py
.py
import sys from pathlib import Path from typing import Any, Dict, List, Literal, Optional, Tuple, Union, cast import attr from pytest import importorskip from omegaconf import II, MISSING, SI from tests import Color, Enum1 if sys.version_info >= (3, 8): # pragma: no cover from typing import TypedDict # attr is...
897
22,487
omegaconf
tests/test_to_yaml.py
.py
import platform from pathlib import Path from textwrap import dedent from typing import Any, Literal, Optional import yaml from pytest import mark from omegaconf import DictConfig, EnumNode, ListConfig, LiteralNode, OmegaConf, _utils from tests import Enum1, User @mark.parametrize( "input_, expected", [ ...
222
6,399
pyomo
examples/pyomo/p-median/decorated_pmedian.py
.py
# ____________________________________________________________________________________ # # Pyomo: Python Optimization Modeling Objects # Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC # Under the terms of Contract DE-NA0003525 with National Technology and Engineering # Solutions of...
59
1,678
openvino
tests/layer_tests/pytorch_tests/test_batch_norm.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import pytest from pytorch_layer_test_class import PytorchLayerTest class TestBatchNorm(PytorchLayerTest): def _prepare_input(self, ndim=4): shape5d = [20, 6, 10, 10, 10] shape = shape5d[:ndim] return (self....
65
2,965
gunicorn
examples/multidomainapp.py
.py
# # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. import re class SubDomainApp: """WSGI application to delegate requests based on domain name. """ def __init__(self, mapping): self.mapping = mapping def __call__(self, environ, start_response)...
36
971
black
src/black/linegen.py
.py
""" Generating lines of code. """ import re import sys from collections.abc import Collection, Iterable, Iterator from dataclasses import replace from enum import Enum, auto from functools import partial, wraps from typing import Union, cast from black.brackets import ( COMMA_PRIORITY, COMPARATOR_PRIORITY, ...
2,253
88,220
wagtail
wagtail/images/views/bulk_actions/add_tags.py
.py
from django import forms from django.utils.translation import gettext_lazy as _ from django.utils.translation import ngettext from wagtail.admin import widgets from wagtail.images.views.bulk_actions.image_bulk_action import ImageBulkAction class TagForm(forms.Form): tags = forms.Field(label=_("Tags"), widget=wid...
45
1,513
pyomo
pyomo/core/base/connector.py
.py
# ____________________________________________________________________________________ # # Pyomo: Python Optimization Modeling Objects # Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC # Under the terms of Contract DE-NA0003525 with National Technology and Engineering # Solutions of...
283
9,359
probability
tensorflow_probability/python/optimizer/bfgs.py
.py
# Copyright 2018 The TensorFlow Probability Authors. # # 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 o...
504
23,493
biopython
Bio/Entrez/__init__.py
.py
# Copyright 1999-2000 by Jeffrey Chang. All rights reserved. # Copyright 2008-2013 by Michiel de Hoon. All rights reserved. # Revisions copyright 2011-2016 by Peter Cock. All rights reserved. # Revisions copyright 2015 by Eric Rasche. All rights reserved. # Revisions copyright 2015 by Carlos Pena. All rights reserved...
748
29,644
mlflow
tests/sagemaker/mock/__init__.py
.py
import json import time from datetime import datetime from typing import Any, NamedTuple from moto.core import DEFAULT_ACCOUNT_ID, BackendDict, BaseBackend, BaseModel from moto.core.models import base_decorator from moto.core.responses import BaseResponse class SageMakerResourceWithArn(NamedTuple): resource: Any...
1,091
41,509
onnx
onnx/reference/ops/_op_common_window.py
.py
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import numpy as np from onnx.helper import tensor_dtype_to_np_dtype from onnx.reference.op_run import OpRun class _CommonWindow(OpRun): @staticmethod def _begin(size, periodic, output_datatype...
27
750
pyomo
pyomo/contrib/alternative_solutions/lp_enum_solnpool.py
.py
# ____________________________________________________________________________________ # # Pyomo: Python Optimization Modeling Objects # Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC # Under the terms of Contract DE-NA0003525 with National Technology and Engineering # Solutions of...
234
8,462
python-prompt-toolkit
examples/prompts/auto-completion/autocomplete-with-control-space.py
.py
#!/usr/bin/env python """ Example of using the control-space key binding for auto completion. """ from prompt_toolkit import prompt from prompt_toolkit.completion import WordCompleter from prompt_toolkit.key_binding import KeyBindings animal_completer = WordCompleter( [ "alligator", "ant", ...
77
1,409
pyro
pyro/distributions/affine_beta.py
.py
# Copyright Contributors to the Pyro project. # SPDX-License-Identifier: Apache-2.0 import torch from torch.distributions import constraints from torch.distributions.transforms import AffineTransform from .torch import Beta, TransformedDistribution from .util import broadcast_shape class AffineBeta(TransformedDistr...
123
3,985
pyomo
pyomo/contrib/simplification/ginac/__init__.py
.py
# ____________________________________________________________________________________ # # Pyomo: Python Optimization Modeling Objects # Copyright (c) 2008-2026 National Technology and Engineering Solutions of Sandia, LLC # Under the terms of Contract DE-NA0003525 with National Technology and Engineering # Solutions of...
51
1,961
beam
sdks/python/apache_beam/examples/wordcount_test.py
.py
# -*- coding: utf-8 -*- # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "L...
69
2,468
lemur
lemur/plugins/lemur_google_ca/plugin.py
.py
""" .. module: lemur.plugins.lemur_google_ca.plugin :platform: Unix :synopsis: This module is responsible for creating certificates with the Google CA API ' :license: Apache, see LICENSE for more details. Google CA (v2 API) Documentation https://cloud.google.com/certificate-authority-service/docs/r...
216
8,037
wandb
wandb/sdk/lib/deprecation.py
.py
from __future__ import annotations from typing import TYPE_CHECKING, TypeAlias import wandb from wandb.sdk.lib import telemetry if TYPE_CHECKING: from wandb.proto.wandb_telemetry_pb2 import Deprecated UNSET: DoNotSet = object() """A temporary default value for removing formerly optional parameters. This helps...
52
1,374
beam
sdks/python/apache_beam/ml/anomaly/univariate/median_test.py
.py
# # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not us...
73
2,066
django-cms
cms/tests/test_nested_plugins.py
.py
from djangocms_text.models import Text from cms.api import add_plugin, create_page from cms.models import Page from cms.models.placeholdermodel import Placeholder from cms.models.pluginmodel import CMSPlugin from cms.tests.test_plugins import PluginsTestBaseCase from cms.utils.plugins import copy_plugins_to_placeholde...
1,234
59,740
coremltools
coremltools/converters/mil/backend/mil/passes/__init__.py
.py
# Copyright (c) 2020, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause from . import (adjust_io_to_supported_types, fuse_activation_silu, insert_image_prepro...
8
355
readthedocs.org
readthedocs/vcs_support/backends/git.py
.py
"""Git-related utilities.""" import re from typing import Iterable from urllib.parse import urlparse import structlog from django.conf import settings from readthedocs.builds.constants import BRANCH from readthedocs.builds.constants import EXTERNAL from readthedocs.builds.constants import STABLE from readthedocs.bui...
615
24,665
jupytext
tests/data/notebooks/outputs/ipynb_to_sphinx/nteract_with_parameter.py
.py
# --- # jupyter: # kernel_info: # name: python3 # kernelspec: # display_name: Python 3 # language: python # name: python3 # --- param = 4 "" import pandas as pd "" df = pd.DataFrame({'A': [1, 2], 'B': [3 + param, 4]}, index=pd.Index(['x0', 'x1'], name='x')) df "" # %matplotlib ...
24
347
wandb
wandb/sdk/launch/agent/config.py
.py
"""Definition of the config object used by the Launch agent.""" from __future__ import annotations from enum import Enum # ValidationError is imported for exception type checking purposes only. from pydantic import ( # type: ignore BaseModel, ConfigDict, Field, ValidationError, field_validator, ...
294
9,263
beam
sdks/python/apache_beam/ml/rag/test_utils.py
.py
# # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not us...
448
16,889
black
src/black/const.py
.py
DEFAULT_LINE_LENGTH = 88 DEFAULT_EXCLUDES = r"/(\.direnv|\.eggs|\.git|\.hg|\.ipynb_checkpoints|\.mypy_cache|\.nox|\.pytest_cache|\.ruff_cache|\.tox|\.svn|\.venv|\.vscode|__pypackages__|_build|buck-out|build|dist|venv)/" # noqa: B950 DEFAULT_INCLUDES = r"(\.pyi?|\.ipynb)$" STDIN_PLACEHOLDER = "__BLACK_STDIN_FILENAME__"...
5
321
conda
tests/_preview/env_setup/test_env_setup.py
.py
# Copyright (C) 2012 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause """Tests for env-setup preview module constants.""" from __future__ import annotations from conda._preview.env_setup import PREVIEW_LABEL def test_preview_label(): """PREVIEW_LABEL must match the kebab-case name used in context.preview."...
13
363
confluent-kafka-python
src/confluent_kafka/avro/__init__.py
.py
#!/usr/bin/env python # # Copyright 2016-2020 Confluent Inc. # # 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 l...
195
8,320
hatch
tests/utils/test_fs.py
.py
import os import pathlib from hatch.utils.fs import Path, temp_chdir, temp_directory class TestPath: def test_type(self): expected_type = type(pathlib.Path()) assert isinstance(Path(), expected_type) assert issubclass(Path, expected_type) def test_resolve_relative_non_existent(self,...
130
3,463
confluent-kafka-python
src/confluent_kafka/_util/__init__.py
.py
# Copyright 2022 Confluent Inc. # # 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, s...
17
691
ipython
IPython/terminal/pt_inputhooks/glut.py
.py
"""GLUT Input hook for interactive use with prompt_toolkit """ # GLUT is quite an old library and it is difficult to ensure proper # integration within IPython since original GLUT does not allow to handle # events one by one. Instead, it requires for the mainloop to be entered # and never returned (there is not even ...
141
4,999
loguru
tests/exceptions/source/others/handler_formatting_with_decorator.py
.py
import sys from loguru import logger logger.remove() logger.add( sys.stderr, format="{name} {file.name} {function} {line}", diagnose=False, backtrace=False, colorize=False, ) @logger.catch def a(): 1 / 0 a()
21
238
django-cms
cms/test_utils/util/fuzzy_int.py
.py
class FuzzyInt(int): def __new__(cls, lowest, highest): obj = super().__new__(cls, highest) obj.lowest = lowest obj.highest = highest return obj def __eq__(self, other): return other >= self.lowest and other <= self.highest def __repr__(self): return "[%d..%...
17
520
bazel
scripts/generate_fish_completion.py
.py
# Copyright 2020 The Bazel Authors. All rights reserved. # # 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 la...
328
11,604
astropy
astropy/constants/si.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ Astronomical and physics constants in SI units. See :mod:`astropy.constants` for a complete listing of constants defined in Astropy. """ from .config import codata, iaudata from .constant import Constant for _nm, _c in (*sorted(vars(codata).items())...
13
473
onnx
onnx/shape_inference.py
.py
# Copyright (c) ONNX Project Contributors # # SPDX-License-Identifier: Apache-2.0 """onnx shape inference. Shape inference is not guaranteed to be complete. """ from __future__ import annotations import os from typing import TYPE_CHECKING import onnx import onnx.onnx_cpp2py_export.shape_inference as C # noqa: N81...
182
5,906
openvino
tests/layer_tests/jax_tests/test_concatenate.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import jax import numpy as np import pytest from jax import numpy as jnp from jax_layer_test_class import JaxLayerTest rng = np.random.default_rng(34455) class TestConcatenate(JaxLayerTest): def _prepare_input(self): inpu...
52
1,889
luigi
luigi/configuration/cfg_parser.py
.py
# -*- coding: utf-8 -*- # # Copyright 2012-2015 Spotify AB # # 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...
209
8,274
probability
tensorflow_probability/python/distributions/joint_distribution_named.py
.py
# Copyright 2018 The TensorFlow Probability Authors. # # 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 o...
598
23,820
beam
sdks/python/apache_beam/examples/avro_nyc_trips_it_test.py
.py
# # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not us...
216
6,512
textual
src/textual/_duration.py
.py
import re _match_duration = re.compile(r"^(-?\d+\.?\d*)(s|ms)$").match class DurationError(Exception): """ Exception indicating a general issue with a CSS duration. """ class DurationParseError(DurationError): """ Indicates a malformed duration string that could not be parsed. """ def _du...
45
1,211
mlflow
mlflow/projects/backend/local.py
.py
import logging import os import platform import posixpath import subprocess import sys from pathlib import Path import mlflow from mlflow import tracking from mlflow.environment_variables import ( MLFLOW_KERBEROS_TICKET_CACHE, MLFLOW_KERBEROS_USER, MLFLOW_PYARROW_EXTRA_CONF, ) from mlflow.exceptions import...
429
17,192
onnx
onnx/reference/ops/op_linear_attention.py
.py
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import numpy as np from onnx.reference.op_run import OpRun def _unpack_3d_to_4d(x: np.ndarray, num_heads: int) -> np.ndarray: """Reshape (B, T, H*D) -> (B, H, T, D).""" b, t, hd = x.shape ...
182
7,881
probability
spinoffs/fun_mc/fun_mc/malt.py
.py
# Copyright 2022 The TensorFlow Probability Authors. # # 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 o...
362
12,832
clearml
clearml/utilities/files.py
.py
import os from sys import platform import pathlib2 import psutil def get_filename_max_length(dir_path: str) -> int: default = 255 # Common filesystems like NTFS, EXT4 and HFS+ limited with 255 try: dir_path = pathlib2.Path(os.path.abspath(dir_path)) if platform == "win32": # noin...
37
1,286
openvino
tests/layer_tests/tensorflow2_keras_tests/test_tf2_keras_zeropadding2d.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import pytest import tensorflow as tf from common.tf2_layer_test_class import CommonTF2LayerTest class TestKerasZeroPadding2D(CommonTF2LayerTest): def create_keras_zeropadding2d_net(self, input_names, input_shapes, input_type, pad...
58
2,788
beam
sdks/python/apache_beam/examples/snippets/transforms/other/create.py
.py
# coding=utf-8 # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License");...
52
1,486
python-dotenv
src/dotenv/__main__.py
.py
"""Entry point for cli, enables execution with `python -m dotenv`""" from .cli import cli if __name__ == "__main__": cli()
7
129
coremltools
deps/pybind11/tests/test_chrono.py
.py
from __future__ import annotations import datetime import pytest import env # noqa: F401 from pybind11_tests import chrono as m def test_chrono_system_clock(): # Get the time from both c++ and datetime date0 = datetime.datetime.today() date1 = m.test_chrono1() date2 = datetime.datetime.today() ...
208
5,727
saleor
saleor/webhook/observability/tests/test_payloads.py
.py
import datetime import json from unittest.mock import patch from uuid import UUID import graphene import pytest from django.http import JsonResponse from ....core import EventDeliveryStatus from ....webhook.event_types import WebhookEventAsyncType from ..exceptions import TruncationError from ..obfuscation import MAS...
492
17,678
saleor
saleor/graphql/payment/mutations/payment/payment_capture.py
.py
import graphene from django.core.exceptions import ValidationError from .....payment import PaymentError, gateway from .....payment.error_codes import PaymentErrorCode from .....payment.utils import mark_checkout_search_index_dirty from .....permission.enums import OrderPermissions from ....core import ResolveInfo fro...
57
2,183
openvino
src/bindings/python/src/openvino/opset11/ops.py
.py
# -*- coding: utf-8 -*- # Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 """Factory functions for all openvino ops.""" from functools import partial from typing import Optional from openvino import Node from openvino.utils.node_factory import _get_node_factory from openvino.utils.deco...
112
4,520
confluent-kafka-python
src/confluent_kafka/_oauthbearer/aws/aws_sts_token_provider.py
.py
# Copyright 2026 Confluent Inc. # # 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, s...
173
6,962
openvino
src/frontends/paddle/tests/test_models/gen_scripts/generate_pad3d.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 # # pad3d paddle model generator # import numpy as np from save_model import saveModel import sys def pad3d(name : str, x, in_dtype, pad, data_format, mode, value = 0): import paddle paddle.enable_static() with paddle.stati...
80
2,693
probability
tensorflow_probability/python/experimental/mcmc/kernel_builder.py
.py
# Copyright 2020 The TensorFlow Probability Authors. # # 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 o...
823
32,517
cvxpy
cvxpy/cvxcore/python/canonInterface.py
.py
""" Copyright 2017 Steven Diamond 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 wr...
315
12,168