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
omegaconf
benchmark/benchmark.py
.py
import copy from typing import Any, Dict, List from pytest import fixture, mark, param from omegaconf import OmegaConf from omegaconf._utils import ValueKind, _is_missing_literal, get_value_kind, split_key def build_dict( d: Dict[str, Any], depth: int, width: int, leaf_value: Any = 1 ) -> Dict[str, Any]: if...
192
4,916
returns
returns/result.py
.py
from abc import ABC from collections.abc import Callable, Generator, Iterator from functools import wraps from inspect import FrameInfo from typing import ( TYPE_CHECKING, Any, Never, TypeAlias, TypeVar, final, overload, ) from typing_extensions import ParamSpec from returns.interfaces.spe...
607
17,705
mkdocs-material
includes/debug/cairo-lookup-windows.py
.py
import os library_names = ("cairo-2", "cairo", "libcairo-2") filenames = ("libcairo.so.2", "libcairo.2.dylib", "libcairo-2.dll") first_found = "" names = [] for name in library_names: if name.lower().endswith(".dll"): names += [name] else: names += [name, name + ".dll"] for name in names: ...
32
884
hydra
tools/copyright/check_new_files.py
.py
#!/usr/bin/env python3 # SPDX-FileCopyrightText: Contributors to Hydra # SPDX-License-Identifier: MIT """Check copyright headers on newly added Python files.""" from __future__ import annotations import argparse import os import re import subprocess import sys from pathlib import Path from typing import Sequence R...
141
3,979
luigi
test/contrib/pai_test.py
.py
# -*- coding: utf-8 -*- # # Copyright 2017 Open Targets # # 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...
92
3,297
qutip
qutip/core/data/solve.py
.py
from qutip.core.data import CSR, Data, csr, Dense, Dia import qutip.core.data as _data import scipy.sparse.linalg as splinalg import numpy as np from qutip.settings import settings import warnings from typing import Union if settings.has_mkl: from qutip._mkl.spsolve import mkl_spsolve else: mkl_spsolve = None ...
235
6,767
jupyterlab
galata/jupyter_server_csp_test_config.py
.py
# Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. from jupyterlab.galata import configure_jupyter_server configure_jupyter_server(c) c.LabApp.dev_mode = True c.ServerApp.allow_origin = "null" c.ServerApp.tornado_settings = {"headers": {"Content-Security-Policy": "san...
10
342
saleor
saleor/account/lock_objects.py
.py
from .models import CustomerType, User def user_qs_select_for_update(): return User.objects.order_by("pk").select_for_update(of=("self",)) def customer_type_qs_select_for_update(): return CustomerType.objects.order_by("pk").select_for_update(of=("self",))
10
268
pyomo
pyomo/contrib/appsi/solvers/maingo_solvermodel.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...
281
10,007
tqdm
examples/7zx.py
.py
"""Usage: 7zx.py [--help | options] <zipfiles>... Options: -h, --help Print this help and exit -v, --version Print version and exit -c, --compressed Use compressed (instead of uncompressed) file sizes -s, --silent Do not print one row per zip file -y, --yes Assume yes to all queries (for ...
118
4,455
openvino
tests/layer_tests/tensorflow_tests/test_tf_Multinomial.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import pytest import tensorflow as tf from common.tf_layer_test_class import CommonTFLayerTest import numpy as np class TestMultinomial(CommonTFLayerTest): def _prepare_input(self, inputs_dict, kwargs): inputs_dict["num_sam...
140
4,935
textual
src/textual/widgets/_label.py
.py
"""Provides a simple Label widget.""" from __future__ import annotations from typing import Literal from textual.visual import VisualType from textual.widgets._static import Static LabelVariant = Literal["success", "error", "warning", "primary", "secondary", "accent"] class Label(Static): """A simple label wi...
74
1,762
beam
sdks/python/apache_beam/runners/worker/worker_pool_main.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...
240
8,343
probability
tensorflow_probability/python/experimental/nn/util/utils.py
.py
# Copyright 2019 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...
456
15,971
saleor
saleor/graphql/payment/tests/mutations/test_payment_gateway_initialize_tokenization.py
.py
from unittest.mock import patch import pytest from .....payment.interface import ( PaymentGatewayInitializeTokenizationRequestData, PaymentGatewayInitializeTokenizationResponseData, PaymentGatewayInitializeTokenizationResult, ) from .....plugins.manager import PluginsManager from ....core.enums import Pay...
261
8,851
saleor
saleor/graphql/order/tests/mutations/test_order_note_update.py
.py
from unittest.mock import ANY, patch import graphene import pytest from django.test import override_settings from .....account.models import CustomerEvent from .....core.models import EventDelivery from .....order import OrderEvents, OrderStatus from .....order.error_codes import OrderNoteUpdateErrorCode from .....or...
327
10,502
loguru
loguru/_error_interceptor.py
.py
import sys import traceback class ErrorInterceptor: def __init__(self, should_catch, handler_id): self._should_catch = should_catch self._handler_id = handler_id def should_catch(self): return self._should_catch def print(self, record=None, *, exception=None): if not sys....
35
1,107
metrics
src/torchmetrics/text/wer.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...
140
5,232
onnxruntime
orttraining/orttraining/test/python/orttraining_test_ortmodule_cache.py
.py
import os import tempfile import unittest.mock import torch from onnxruntime.training.ortmodule import DebugOptions, LogLevel, ORTModule torch.distributed.init_process_group(backend="nccl") class Net(torch.nn.Module): def __init__(self): super().__init__() self.fc = torch.nn.Linear(10, 1) ...
47
1,412
pyro
pyro/contrib/funsor/infer/trace_elbo.py
.py
# Copyright Contributors to the Pyro project. # SPDX-License-Identifier: Apache-2.0 import contextlib import funsor from pyro.contrib.funsor import to_data, to_funsor from pyro.contrib.funsor.handlers import enum, plate, replay, trace from pyro.contrib.funsor.infer import config_enumerate from pyro.distributions.uti...
53
1,724
saleor
saleor/attribute/models/product.py
.py
from django.contrib.postgres.indexes import BTreeIndex from django.db import models from ...core.models import SortableModel from ...product.models import Product, ProductType from .base import AssociatedAttributeManager class AssignedProductAttributeValue(SortableModel): value = models.ForeignKey( "Attr...
51
1,461
pyomo
pyomo/common/fileutils.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...
891
30,394
luigi
luigi/task.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...
1,033
36,723
metrics
src/torchmetrics/functional/regression/crps.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...
100
3,767
openvino
tests/e2e_tests/pipelines/pipeline_templates/input_templates.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 def read_npz_input(path): return "read_input", {"npz": {"path": path}} def read_npy_input(path): return "read_input", {"npy": {"inputs_map": path}} def read_ark_input(path): return "read_input", {"ark": {"inputs_map": pat...
34
764
beam
sdks/python/apache_beam/examples/snippets/transforms/aggregation/groupby_simple_aggregate.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");...
67
2,131
openvino
tests/layer_tests/tensorflow_tests/test_tf_ReLU6.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import pytest from common.tf_layer_test_class import CommonTFLayerTest class TestReLU6(CommonTFLayerTest): def create_relu6_net(self, shape, ir_version): import tensorflow as tf tf.compat.v1.reset_default_graph() ...
47
1,644
wagtail
wagtail/users/tests/__init__.py
.py
from .test_admin_views import ( CustomGroupViewSet, ) __all__ = [ "CustomGroupViewSet", ]
8
99
mlflow
mlflow/demo/__init__.py
.py
import logging import mlflow.demo.generators # noqa: F401 from mlflow.demo.base import DEMO_EXPERIMENT_NAME, DEMO_PROMPT_PREFIX, BaseDemoGenerator, DemoResult from mlflow.demo.registry import demo_registry from mlflow.utils.workspace_context import WorkspaceContext, get_request_workspace _logger = logging.getLogger(...
49
1,799
voila
tests/app/cgi-test.py
.py
import pytest NOTEBOOK_PATH = "cgi.ipynb" @pytest.fixture def notebook_cgi_path(base_url): return base_url + f"voila/render/{NOTEBOOK_PATH}" @pytest.fixture def voila_args(notebook_directory, voila_args_extra): return ["--VoilaTest.root_dir=%r" % notebook_directory, *voila_args_extra] async def test_cgi_...
20
552
coremltools
coremltools/converters/mil/mil/visitors/dot_visitor.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 ..var import Var def _get_input_vars(op, only_nonconst_vars=False): """ Return type : ...
207
6,100
probability
discussion/adaptive_malt/adaptive_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...
2,011
72,125
beam
sdks/python/apache_beam/testing/benchmarks/nexmark/queries/winning_bids.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...
197
7,124
astropy
astropy/timeseries/periodograms/bls/core.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst __all__ = ["BoxLeastSquares", "BoxLeastSquaresResults"] import numpy as np from astropy import units from astropy import units as u from astropy.time import Time, TimeDelta from astropy.timeseries.periodograms.base import BasePeriodogram from astropy.ti...
878
34,147
wandb
wandb/sdk/artifacts/_generated/__init__.py
.py
# Generated by ariadne-codegen __all__ = [ "ADD_ALIASES_GQL", "ADD_ARTIFACT_COLLECTION_TAGS_GQL", "ARTIFACT_BY_ID_GQL", "ARTIFACT_COLLECTION_ALIASES_GQL", "ARTIFACT_CREATED_BY_GQL", "ARTIFACT_MEMBERSHIP_BY_NAME_GQL", "ARTIFACT_MEMBERSHIP_FILES_GQL", "ARTIFACT_TYPE_ARTIFACT_COLLECTIONS_G...
297
9,893
textual
tests/directory_tree/test_change_path.py
.py
from pathlib import Path from textual.app import App, ComposeResult from textual.widgets import DirectoryTree class DirectoryTreeApp(App[None]): def compose(self) -> ComposeResult: yield DirectoryTree(".") async def test_change_directory_tree_path(tmpdir: Path) -> None: """The DirectoryTree should...
21
646
mlflow
mlflow/utils/file_utils.py
.py
import atexit import codecs import errno import fnmatch import gzip import importlib.util import json import logging import math import os import pathlib import posixpath import shutil import stat import subprocess import sys import tarfile import tempfile import time import urllib.parse import urllib.request from conc...
987
32,784
mkdocs
mkdocs/tests/config/config_options_tests.py
.py
from __future__ import annotations import contextlib import copy import io import logging import os import re import sys import textwrap import unittest from typing import TYPE_CHECKING, Any, Dict, List, Optional, TypeVar, Union from unittest import mock if TYPE_CHECKING: from typing_extensions import assert_type...
2,421
84,508
cvxpy
cvxpy/atoms/elementwise/log1p.py
.py
""" Copyright 2013 Steven Diamond, Eric Chu 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...
73
2,307
luigi
test/contrib/bigquery_test.py
.py
# -*- coding: utf-8 -*- # # Copyright 2019 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 or a...
168
6,164
mkdocs-material
material/plugins/tags/structure/listing/__init__.py
.py
# Copyright (c) 2016-2025 Martin Donath <martin.donath@squidfunk.com> # 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, c...
224
7,935
onnxruntime
onnxruntime/contrib_ops/cuda/llm/generate_kernels.py
.py
# Copyright (c) 2020-2023, NVIDIA CORPORATION. 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 require...
401
14,069
tqdm
tqdm/contrib/concurrent.py
.py
""" Thin wrappers around `concurrent.futures`. """ import sys from contextlib import contextmanager from operator import length_hint from ..auto import tqdm as tqdm_auto from ..std import TqdmWarning __author__ = {"github.com/": ["casperdcl"]} __all__ = ['thread_map', 'process_map', 'interpreter_map'] class _Interp...
260
9,849
deap
doc/code/tutorials/part_2/2_2_4_evolution_strategy.py
.py
## 2.2.4 Evolution Strategy import array import random from deap import base from deap import creator from deap import tools creator.create("FitnessMin", base.Fitness, weights=(-1.0,)) creator.create("Individual", array.array, typecode="d", fitness=creator.FitnessMin, strategy=None) creator.create("Str...
27
832
beam
learning/katas/python/Core Transforms/Side Output/Side Output/task.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...
57
1,878
onnx
onnx/reference/ops/aionnxml/op_tree_ensemble.py
.py
from __future__ import annotations from enum import IntEnum from typing import TYPE_CHECKING import numpy as np from onnx.reference.ops.aionnxml._op_run_aionnxml import OpRunAiOnnxMl if TYPE_CHECKING: from collections.abc import Callable class AggregationFunction(IntEnum): AVERAGE = 0 SUM = 1 MIN ...
269
9,388
coveragepy
tests/modules/pkg1/__main__.py
.py
# Used in the tests for PyRunner import sys print("pkg1.__main__: passed %s" % sys.argv[1])
5
93
mlflow
mlflow/db.py
.py
import click @click.group("db") def commands(): """ Commands for managing an MLflow tracking database. """ @commands.command() @click.argument("url") def upgrade(url): """ Upgrade the schema of an MLflow tracking database to the latest supported version. **IMPORTANT**: Schema migrations can...
359
12,646
hatch
src/hatch/template/default.py
.py
from hatch.template import File, files_default, find_template_files from hatch.template.plugin.interface import TemplateInterface from hatch.utils.fs import Path from hatch.utils.network import download_file class DefaultTemplate(TemplateInterface): PLUGIN_NAME = "default" def __init__(self, *args, **kwargs)...
130
5,226
mlflow
mlflow/gateway/budget_tracker/__init__.py
.py
"""Budget tracker for AI Gateway cost management. Provides an abstract BudgetTracker interface and window computation helpers. The concrete InMemoryBudgetTracker lives in ``budget_tracker.in_memory``. """ from __future__ import annotations import threading import time from abc import ABC, abstractmethod from datacla...
256
9,435
sphinx
sphinx/util/cfamily.py
.py
"""Utility functions common to the C and C++ domains.""" from __future__ import annotations import re from copy import deepcopy from typing import TYPE_CHECKING from docutils import nodes from sphinx import addnodes from sphinx.util import logging if TYPE_CHECKING: from collections.abc import Callable, Sequenc...
526
16,892
probability
tensorflow_probability/python/distributions/two_piece_normal.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...
686
24,837
sphinx
sphinx/util/_importer.py
.py
from __future__ import annotations from importlib import import_module from typing import TYPE_CHECKING from sphinx.errors import ExtensionError if TYPE_CHECKING: from typing import Any def import_object(object_name: str, /, source: str = '') -> Any: """Import python object by qualname.""" obj_path = o...
31
941
ipython
IPython/core/magics/auto.py
.py
"""Implementation of magic functions that control various automatic behaviors. """ from __future__ import annotations #----------------------------------------------------------------------------- # Copyright (c) 2012 The IPython Development Team. # # Distributed under the terms of the Modified BSD License. # # The ...
146
4,835
astropy
astropy/cosmology/_src/tests/traits/test_trait_photoncomponent.py
.py
import numpy as np import pytest from astropy.cosmology._src.traits.photoncomponent import PhotonComponent from astropy.tests.helper import assert_quantity_allclose from .helper import is_positional_only class DummyPhoton(PhotonComponent): Ogamma0 = 1e-4 def inv_efunc(self, z): return np.ones_like(...
26
633
scikit-optimize
skopt/sampler/sobol.py
.py
""" Authors: Original FORTRAN77 version of i4_sobol by Bennett Fox. MATLAB version by John Burkardt. PYTHON version by Corrado Chisari Original Python version of is_prime by Corrado Chisari Original MATLAB versions of other functions by John Burkardt. PYTHON versions by Corrado Chisari ...
429
15,086
lemur
lemur/plugins/lemur_acme/tests/test_acme_handler.py
.py
import unittest from unittest.mock import patch, Mock from cryptography.x509 import DNSName from flask import Flask from lemur.plugins.lemur_acme import acme_handlers from lemur.tests.vectors import ( ACME_CHAIN_SHORT_STR, ACME_CHAIN_LONG_STR, SAN_CERT_STR, ) class TestAcmeHandler(unittest.TestCase): ...
172
7,358
saleor
saleor/graphql/translations/resolvers.py
.py
from ...attribute import AttributeType from ...attribute import models as attribute_models from ...discount import models as discount_models from ...menu import models as menu_models from ...page import models as page_models from ...product import models as product_models from ...shipping import interface as shipping_i...
119
4,095
mlflow
tests/system_metrics/test_system_metrics_logging.py
.py
import logging import threading import time from typing import Any, Callable from unittest import mock import pytest import mlflow from mlflow.entities import Metric, Run, RunData, RunInfo from mlflow.exceptions import MlflowException from mlflow.system_metrics.system_metrics_monitor import SystemMetricsMonitor @py...
320
11,524
probability
spinoffs/inference_gym/inference_gym/targets/lorenz_system_test.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...
197
7,913
wagtail
wagtail/contrib/styleguide/views.py
.py
import os import re from collections import defaultdict import swapper from django import forms from django.core.paginator import Paginator from django.template.loader import render_to_string from django.utils.translation import gettext as _ from django.views.generic.base import TemplateView from wagtail import hooks...
175
6,499
readthedocs.org
readthedocs/allauth/providers/githubapp/views.py
.py
"""Copied from allauth.socialaccount.providers.github.views.""" from allauth.socialaccount.providers.github.views import GitHubOAuth2Adapter from allauth.socialaccount.providers.oauth2.views import OAuth2CallbackView from allauth.socialaccount.providers.oauth2.views import OAuth2LoginView class GitHubAppOAuth2Adapte...
14
518
pyro
setup.py
.py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 import os import subprocess import sys from setuptools import find_packages, setup PROJECT_PATH = os.path.dirname(os.path.abspath(__file__)) VERSION = """ # This file is auto-generated with the version information during setup.py...
163
4,865
pyomo
pyomo/core/plugins/transform/add_slack_vars.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...
354
13,367
conda
conda/base/__init__.py
.py
# Copyright (C) 2012 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause """ Code in ``conda.base`` is the lowest level of the application stack. It is loaded and executed virtually every time the application is executed. Any code within, and any of its imports, must be highly performant. Conda modules importable f...
19
520
saleor
saleor/tests/e2e/promotions/test_promotions_query_with_different_parameters.py
.py
import datetime import pytest from django.utils import timezone from freezegun import freeze_time from ..metadata.utils import update_metadata from ..promotions.utils import create_promotion, promotions_query from ..sales.utils import create_sale from ..utils import assign_permissions # Should be able to query promo...
463
14,048
python-prompt-toolkit
src/prompt_toolkit/search.py
.py
""" Search operations. For the key bindings implementation with attached filters, check `prompt_toolkit.key_binding.bindings.search`. (Use these for new key bindings instead of calling these function directly.) """ from __future__ import annotations from enum import Enum from typing import TYPE_CHECKING from .appli...
227
6,951
textual
src/textual/content.py
.py
""" Content is a container for text, with spans marked up with color / style. It is equivalent to Rich's Text object, with support for more of Textual features. Unlike Rich Text, Content is *immutable* so you can't modify it in place, and most methods will return a new Content instance. This is more like the builtin s...
1,843
62,237
coremltools
deps/pybind11/tests/test_custom_type_casters.py
.py
from __future__ import annotations import pytest from pybind11_tests import custom_type_casters as m def test_noconvert_args(msg): a = m.ArgInspector() assert ( msg(a.f("hi")) == """ loading ArgInspector1 argument WITH conversion allowed. Argument value = hi """ ) assert...
125
4,028
saleor
saleor/checkout/tests/fixtures/checkout_line_info.py
.py
import pytest from ...fetch import fetch_checkout_lines @pytest.fixture def checkout_lines_info(checkout_with_items, categories, published_collections): lines = checkout_with_items.lines.all() category1, category2 = categories product1 = lines[0].variant.product product1.category = category1 pro...
45
1,271
saleor
saleor/tests/e2e/promotions/test_staff_can_change_reward_value_type_in_promotion_rule.py
.py
import pytest from ....product.tasks import recalculate_discounted_price_for_products_task from ..product.utils import get_product from ..product.utils.preparing_product import prepare_product from ..shop.utils.preparing_shop import prepare_default_shop from ..utils import assign_permissions from .utils import create_...
107
3,889
saleor
saleor/site/tests/fixtures/site_settings.py
.py
import pytest from ....menu.models import Menu from ...models import Site, SiteSettings @pytest.fixture(autouse=True) def site_settings(db, settings) -> SiteSettings: """Create a site and matching site settings. This fixture is autouse because django.contrib.sites.models.Site and saleor.site.models.Site...
46
1,549
wagtail
docs/conf.py
.py
# # Wagtail documentation build configuration file, created by # sphinx-quickstart on Tue Jan 14 17:38:55 2014. # # This file is execfile()d with the current directory set to its # containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values ...
459
14,778
openvino
tests/layer_tests/onnx_tests/test_pooling.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import numpy as np import pytest pytest.importorskip("openvino.tools.mo", reason="Ticket - 157136") from common.layer_test_class import check_ir_version from common.onnx_layer_test_class import OnnxRuntimeLayerTest, onnx_make_model fro...
494
23,482
gunicorn
tests/requests/valid/003.py
.py
# # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. request = { "method": "GET", "uri": uri("/favicon.ico"), "version": (1, 1), "headers": [ ("HOST", "0.0.0.0=5000"), ("USER-AGENT", "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9) Gec...
21
683
hatch
src/hatch/config/utils.py
.py
from __future__ import annotations from typing import TYPE_CHECKING import tomlkit if TYPE_CHECKING: from tomlkit.items import InlineTable from tomlkit.toml_document import TOMLDocument from hatch.utils.fs import Path def save_toml_document(document: TOMLDocument, path: Path): path.ensure_parent_d...
21
491
omegaconf
tests/data/load.py
.py
import pickle import sys from omegaconf import OmegaConf with open(f"{sys.argv[1]}.pickle", mode="rb") as fp: cfg = pickle.load(fp) assert cfg == OmegaConf.create({"a": [{"b": 10}]})
9
193
pyomo
pyomo/contrib/pynumero/intrinsic.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...
451
18,642
rq
rq/worker/base.py
.py
from __future__ import annotations import inspect import logging import math import os import random import signal import socket import sys import time import warnings from collections.abc import Callable, Sequence from datetime import datetime, timedelta from enum import Enum from random import shuffle from types imp...
1,739
72,669
beam
sdks/python/apache_beam/examples/snippets/transforms/aggregation/min_globally.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");...
54
1,572
httpie
httpie/encoding.py
.py
from typing import Union, Tuple from charset_normalizer import from_bytes from charset_normalizer.constant import TOO_SMALL_SEQUENCE UTF8 = 'utf-8' ContentBytes = Union[bytearray, bytes] def detect_encoding(content: ContentBytes) -> str: """ We default to UTF-8 if text too short, because the detection ...
51
1,385
lemur
lemur/destinations/schemas.py
.py
""" .. module: lemur.destinations.schemas :platform: unix :copyright: (c) 2018 by Netflix Inc., see AUTHORS for more :license: Apache, see LICENSE for more details. .. moduleauthor:: Kevin Glisson <kglisson@netflix.com> """ from marshmallow import fields, post_dump from lemur.auth.permissions import admin_...
52
1,780
mlflow
dev/benchmarks/gateway/fake_server.py
.py
# /// script # requires-python = ">=3.10" # dependencies = ["fastapi>=0.115.0,<1", "uvicorn[standard]>=0.30.0,<1"] # /// """Fake OpenAI-compatible server for benchmarking. Returns synthetic responses after a configurable delay so benchmarks measure MLflow overhead rather than provider latency. Run standalone: uv ...
69
1,859
onnxruntime
onnxruntime/python/tools/onnxruntime_test.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- from __future__ import annotations import argparse import os import sys ...
165
5,606
saleor
saleor/account/tests/test_utils.py
.py
from unittest.mock import patch import pytest from django.test import override_settings from ...checkout import AddressType from ...plugins.manager import get_plugins_manager from ..models import Address, User from ..utils import ( get_user_groups_permissions, is_user_address_limit_reached, remove_the_old...
333
11,053
saleor
saleor/giftcard/gateway.py
.py
from decimal import Decimal from typing import Annotated from uuid import uuid4 import pydantic from django.db import transaction from django.db.models import Exists, F, OuterRef, Q from django.utils import timezone from ..account.models import User from ..app.models import App from ..checkout.models import Checkout ...
449
16,705
conda
tests/cli/test_config.py
.py
# Copyright (C) 2012 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause from __future__ import annotations import json import re import sys from contextlib import contextmanager, nullcontext from textwrap import dedent from typing import TYPE_CHECKING import pytest from ruamel.yaml.scanner import ScannerError fro...
947
31,200
onnxruntime
tools/python/util/optimize_onnx_model.py
.py
#!/usr/bin/env python3 # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. from __future__ import annotations import argparse import os import pathlib from .onnx_model_utils import get_optimization_level, optimize_model def optimize_model_helper(): parser = argparse.Arg...
57
1,959
pyro
tests/contrib/forecast/test_forecaster.py
.py
# Copyright Contributors to the Pyro project. # SPDX-License-Identifier: Apache-2.0 import pytest import torch import pyro import pyro.distributions as dist import pyro.poutine as poutine from pyro.contrib.forecast import Forecaster, ForecastingModel, HMCForecaster from pyro.infer.autoguide import AutoDelta from pyro...
331
11,591
pyomo
pyomo/contrib/mindtpy/cut_generation.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...
498
19,327
textual
tests/snapshot_tests/snapshot_apps/remove_tab.py
.py
from textual.app import App from textual.binding import Binding from textual.widgets import Label, TabbedContent, TabPane class ReproApp(App[None]): BINDINGS = [ Binding("space", "close_pane"), ] def __init__(self): super().__init__() self.animation_level = "none" def compose...
31
793
pyomo
pyomo/solvers/tests/checks/test_KNITROAMPL.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...
123
4,338
django-cms
cms/test_utils/project/pluginapp/plugins/manytomany_rel/admin.py
.py
from django.contrib import admin from django.contrib.admin import ModelAdmin from cms.test_utils.project.pluginapp.plugins.manytomany_rel.models import ( Article, Section, ) admin.site.register(Section, ModelAdmin) admin.site.register(Article, ModelAdmin)
11
266
saleor
saleor/graphql/account/filters.py
.py
import django_filters from django.db.models import Count, Exists, OuterRef, Q, QuerySet, Subquery from django.db.models.functions import Coalesce from ...account.models import Address, CustomerType, User from ...attribute.models import ( AssignedUserAttributeValue, AttributeCustomerType, AttributeValue, ) ...
428
13,499
sqlmap
tamper/unmagicquotes.py
.py
#!/usr/bin/env python """ Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org) See the file 'LICENSE' for copying permission """ import re from lib.core.compat import xrange from lib.core.enums import PRIORITY __priority__ = PRIORITY.NORMAL def dependencies(): pass def tamper(payload, **kwargs): ...
54
1,305
sqlmap
extra/dbwire/tds.py
.py
#!/usr/bin/env python """ Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org) See the file 'LICENSE' for copying permission """ """ Minimal pure-python TDS (Tabular Data Stream) client for Microsoft SQL Server (stdlib only). LOGIN7 / TDS 7.4 is the Microsoft dialect. Sybase ASE speaks TDS 5.0 - same 8-byt...
631
27,852
saleor
saleor/tests/e2e/orders/test_cannot_fullfill_order_with_invalid_shipping_method.py
.py
import pytest from .. import DEFAULT_ADDRESS from ..product.utils.preparing_product import prepare_product from ..shop.utils import prepare_shop from ..utils import assign_permissions from .utils.draft_order_complete import raw_draft_order_complete from .utils.draft_order_create import draft_order_create from .utils.d...
151
4,433
saleor
saleor/graphql/product/tests/mutations/test_product_variants_reorder.py
.py
import graphene from .....graphql.tests.utils import get_graphql_content from .....product.error_codes import ProductErrorCode REORDER_PRODUCT_VARIANTS_MUTATION = """ mutation ProductVariantReorder($product: ID!, $moves: [ReorderInput!]!) { productVariantReorder(productId: $product, moves: $moves) { ...
81
2,486
saleor
saleor/graphql/meta/mutations/utils.py
.py
import warnings from django.contrib.postgres.fields import ArrayField from django.core.exceptions import ValidationError from django.db.models import F, Func, JSONField, TextField, Value from django.utils import timezone from ....checkout.models import Checkout, CheckoutMetadata from ....checkout.utils import get_or_...
180
6,014
biopython
setup.py
.py
#!/usr/bin/env python """Freely available tools for computational molecular biology.""" from setuptools import setup import sys import warnings _DEPRECATION_MESSAGE = ( "Invoking setup.py is deprecated and will be removed in a future release of Biopython.\n" "Please use `pip install` or `python -m build` ins...
20
681