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
pyomo
pyomo/contrib/pynumero/sparse/mpi_block_matrix.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...
1,268
45,378
beam
sdks/python/apache_beam/typehints/batch.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...
297
9,514
cvxpy
cvxpy/reductions/dcp2cone/canonicalizers/indicator_canon.py
.py
""" Copyright 2013 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 writing, software...
23
773
saleor
saleor/graphql/order/tests/mutations/test_order_grant_refund_update_reason.py
.py
from decimal import Decimal import graphene import pytest from .....order import OrderGrantedRefundStatus from .....page.models import Page, PageType from ....core.utils import to_global_id_or_none from ....tests.utils import ( get_graphql_content, ) from ...enums import ( OrderGrantRefundUpdateErrorCode, ) ...
738
21,100
probability
tensorflow_probability/python/experimental/util/trainable.py
.py
# 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 # # Unless required by applicable law o...
210
8,789
beam
playground/infrastructure/logger.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 use ...
49
1,784
onnxruntime
onnxruntime/test/python/quantization/test_op_resize.py
.py
#!/usr/bin/env python # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # ---------------------------------------------------------------...
211
7,988
metrics
src/torchmetrics/detection/ciou.py
.py
# Copyright The PyTorch 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 i...
196
8,176
pyro
pyro/poutine/mask_messenger.py
.py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 from typing import TYPE_CHECKING, Union import torch from pyro.poutine.messenger import Messenger if TYPE_CHECKING: from pyro.poutine.runtime import Message class MaskMessenger(Messenger): """ Given a stochastic fu...
41
1,394
sphinx
tests/test_intl/test_intl.py
.py
"""Test message patching for internationalization purposes. Runs the text builder in the test root. """ from __future__ import annotations import os import re import shutil import time from typing import TYPE_CHECKING import pygments import pytest from babel.messages import mofile, pofile from babel.messages.catalo...
2,145
70,345
jupyterlab
jupyterlab/__init__.py
.py
"""Server extension for JupyterLab.""" # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. from ._version import __version__ # noqa from .serverextension import load_jupyter_server_extension # noqa from .handlers.announcements import ( CheckForUpdate, # noqa ...
23
661
cvxpy
cvxpy/reductions/solvers/conic_solvers/__init__.py
.py
""" Copyright 2013 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 writing, software...
44
1,409
textual
tests/listview/test_listview_remove_items.py
.py
from __future__ import annotations import pytest from textual.app import App, ComposeResult from textual.widgets import Label, ListItem, ListView class EmptyListViewApp(App[None]): def compose(self) -> ComposeResult: yield ListView() async def test_listview_pop_empty_raises_index_error(): app = Em...
117
4,121
openvino
tools/commit_slider/utils/cfg_manager.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import json import os class CfgManager(): def __init__(self, cfg) -> None: self.cfg = cfg @staticmethod def singlestepStrFormat(input: str, placeholder: str, substitution: str): return input.replace( ...
219
7,716
beam
sdks/python/apache_beam/ml/rag/ingestion/cloudsql.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...
262
9,638
saleor
saleor/graphql/meta/permissions.py
.py
from collections.abc import Callable from typing import Any from django.core.exceptions import ValidationError from django.db.models import Exists, OuterRef from ...account import models as account_models from ...account.error_codes import AccountErrorCode from ...attribute import AttributeType from ...attribute impo...
395
13,225
beam
sdks/python/apache_beam/ml/transforms/embeddings/open_ai_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...
287
10,089
wandb
wandb/sdk/data_types/bokeh.py
.py
from __future__ import annotations import codecs import json import os import pathlib from typing import TYPE_CHECKING from wandb import util from wandb._strutils import nameof from wandb.sdk.lib import runid from . import _dtypes from ._private import MEDIA_TMP from .base_types.media import Media if TYPE_CHECKING:...
100
3,384
saleor
saleor/graphql/discount/tests/queries/test_sales_sorting.py
.py
import pytest from django.utils import timezone from .....discount import RewardValueType from .....discount.models import Promotion, PromotionRule from ....tests.utils import assert_graphql_error_with_message, get_graphql_content @pytest.fixture def sales_for_sorting_with_channels(db, channel_USD, channel_PLN): ...
324
9,590
sphinx
tests/roots/test-ext-extlinks-hardcoded-urls-multiple-replacements/conf.py
.py
extensions = ['sphinx.ext.extlinks'] extlinks = { 'user': ('https://github.com/%s', '@%s'), 'repo': ('https://github.com/%s', 'project %s'), } extlinks_detect_hardcoded_links = True
7
190
openvino
tests/layer_tests/tensorflow2_keras_tests/test_tf2_keras_concatenate.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 TestKerasConcatenate(CommonTF2LayerTest): def create_keras_concatenate_net(self, axis, input_names, input_shapes, input_type, i...
65
2,981
pyomo
pyomo/core/tests/unit/test_sos.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...
248
7,824
ipython
tools/tests/embed/embed3.py
.py
"""This tests passing local_ns and global_ns (for backwards compatibility only) at activation of an embedded shell.""" from IPython.terminal.embed import InteractiveShellEmbed user_ns = dict(cookie='monster') ISE = InteractiveShellEmbed(banner1='check cookie in locals, and globals empty') ISE(local_ns=user_ns, global_...
8
327
mlflow
mlflow/tracking/_model_registry/registry.py
.py
import inspect import threading from functools import lru_cache from mlflow.tracking.registry import StoreRegistry _building_store_lock = threading.Lock() class ModelRegistryStoreRegistry(StoreRegistry): """Scheme-based registry for model registry store implementations This class allows the registration of...
68
3,251
sqlmap
plugins/dbms/presto/fingerprint.py
.py
#!/usr/bin/env python """ Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org) See the file 'LICENSE' for copying permission """ from lib.core.common import Backend from lib.core.common import Format from lib.core.common import hashDBRetrieve from lib.core.common import hashDBWrite from lib.core.data import...
159
6,052
black
tests/data/cases/f_docstring.py
.py
def foo(e): f""" {'.'.join(e)}""" def bar(e): f"{'.'.join(e)}" def baz(e): F""" {'.'.join(e)}""" # output def foo(e): f""" {'.'.join(e)}""" def bar(e): f"{'.'.join(e)}" def baz(e): f""" {'.'.join(e)}"""
21
234
clearml
clearml/binding/frameworks/fastai_bind.py
.py
import sys from typing import Callable, TYPE_CHECKING, Any import numpy as np from clearml.utilities.version import Version from . import _patched_call from .tensorflow_bind import IsTensorboardInit from .tensorflow_bind import WeightsGradientHistHelper from ..import_bind import PostImportHookPatching from ...debuggi...
354
13,610
omegaconf
tests/examples/test_postponed_annotations.py
.py
def test_simple_types_class_postponed() -> None: # import from a module which has `from __future__ import annotations` from tests.examples.dataclass_postponed_annotations import simple_types_class simple_types_class() def test_conversions_postponed() -> None: # import from a module which has `from __...
13
443
openvino
docs/optimization_guide/nncf/ptq/code/ptq_aa_onnx.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 #! [dataset] import nncf import torch calibration_loader = torch.utils.data.DataLoader(...) def transform_fn(data_item): images, _ = data_item return {input_name: images.numpy()} # input_name should be taken from the model, ...
79
2,243
saleor
saleor/graphql/attribute/enums.py
.py
from enum import Enum from typing import Final import graphene from ...attribute import AttributeEntityType, AttributeInputType, AttributeType from ..core.doc_category import DOC_CATEGORY_ATTRIBUTES from ..core.enums import to_enum from ..core.utils import str_to_enum AttributeInputTypeEnum: Final[graphene.Enum] = t...
29
939
sphinx
tests/test_markup/test_markup.py
.py
"""Test various Sphinx-specific markup extensions.""" from __future__ import annotations import re from types import SimpleNamespace import pytest from docutils import nodes, utils from docutils.parsers.rst import Parser as RstParser from sphinx import addnodes from sphinx.builders.latex import LaTeXBuilder from sp...
790
28,313
conda
tests/common/test_logic.py
.py
# Copyright (C) 2012 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause from itertools import chain, combinations, permutations, product import pytest from conda.common.logic import FALSE, TRUE, Clauses, minimal_unsatisfiable_subset from conda.testing.helpers import raises # These routines implement logical tests...
422
13,074
qutip
qutip/about.py
.py
""" Command line output of information on QuTiP and dependencies. """ __all__ = ['about'] import sys import importlib.metadata import platform from pathlib import Path import numpy import scipy import inspect import qutip from qutip.settings import _blas_info, settings def about(): """ About box for QuTiP. G...
99
3,147
ipython
IPython/core/events.py
.py
"""Infrastructure for registering and firing callbacks on application events. Unlike :mod:`IPython.core.hooks`, which lets end users set single functions to be called at specific times, or a collection of alternative methods to try, callbacks are designed to be used by extension authors. A number of callbacks can be r...
181
6,017
mkdocs-material
material/plugins/typeset/config.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...
31
1,483
sqlmap
plugins/dbms/hsqldb/__init__.py
.py
#!/usr/bin/env python """ Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org) See the file 'LICENSE' for copying permission """ from lib.core.enums import DBMS from lib.core.settings import HSQLDB_SYSTEM_DBS from lib.core.unescaper import unescaper from plugins.dbms.hsqldb.enumeration import Enumeration fr...
30
908
wandb
wandb/automations/_generated/integrations_by_entity.py
.py
# Generated by ariadne-codegen # Source: tools/graphql_codegen/automations/ from __future__ import annotations from typing import Annotated, Literal from pydantic import Field from wandb._pydantic import GQLResult, Typename from .fragments import PageInfoFields, SlackIntegrationFields, WebhookIntegrationFields c...
48
1,363
astropy
astropy/samp/web_profile.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst from urllib.parse import parse_qs from urllib.request import urlopen from astropy.utils.data import get_pkg_data_contents from .standard_profile import SAMPSimpleXMLRPCRequestHandler, ThreadingXMLRPCServer __all__ = [] CROSS_DOMAIN = get_pkg_data_con...
181
5,739
textual
src/textual/canvas.py
.py
""" A Canvas class used to render keylines. !!! note This API is experimental, and may change in the near future. """ from __future__ import annotations import sys from array import array from collections import defaultdict from dataclasses import dataclass from operator import itemgetter from typing import Nam...
285
8,420
pdm
src/pdm/models/caches.py
.py
from __future__ import annotations import contextlib import hashlib import json import os import stat from collections.abc import Iterable from functools import cache from pathlib import Path from typing import TYPE_CHECKING, Generic, TypeVar from packaging.utils import canonicalize_name, parse_wheel_filename from p...
317
11,822
structlog
show_off.py
.py
""" Show how console logging looks like. This is used for the screenshot in the readme and <https://www.structlog.org/en/stable/development.html>. """ from dataclasses import dataclass import structlog @dataclass class SomeClass: x: int y: str structlog.stdlib.recreate_defaults() # so we have logger nam...
50
1,093
sqlmap
lib/core/patch.py
.py
#!/usr/bin/env python """ Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org) See the file 'LICENSE' for copying permission """ import codecs import difflib import inspect import logging import os import random import re import sys import lib.controller.checks import lib.core.common import lib.core.conver...
250
8,435
pdm
tests/test_installer_manager.py
.py
from __future__ import annotations import pytest from pdm.exceptions import UninstallError from pdm.installers.manager import InstallManager def test_install_passes_candidate_options(mocker): environment = mocker.sentinel.environment candidate = mocker.Mock() candidate.req.editable = False candidate...
124
4,465
openvino
src/frontends/onnx/docs/check_supported_ops.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import os import re import sys from pathlib import Path def run_in_ci(): if "CI" in os.environ and os.environ["CI"].lower() == "true": return True if "TF_BUILD" in os.environ and len(os.environ["TF_BUILD"]): ret...
153
6,066
textual
docs/examples/guide/layout/grid_layout3_row_col_adjust.py
.py
from textual.app import App, ComposeResult from textual.widgets import Static class GridLayoutExample(App): CSS_PATH = "grid_layout3_row_col_adjust.tcss" def compose(self) -> ComposeResult: yield Static("One", classes="box") yield Static("Two", classes="box") yield Static("Three", cla...
20
536
metrics
src/torchmetrics/utilities/enums.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...
154
3,688
mlflow
mlflow/server/auth/logo.py
.py
# ruff: noqa: E501 MLFLOW_LOGO = """ <svg width="109" height="40" viewBox="0 0 109 40" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M0 31.0316V15.5024H3.54258V17.4699C4.43636 15.8756 6.38278 15.045 8.13589 15.045C10.178 15.045 11.9636 15.9713 12.7943 17.7895C14.0096 15.7474 15.8278 15.045 17.8373 15.045C20....
15
2,660
mlflow
tests/entities/test_span.py
.py
import json from datetime import datetime from unittest import mock import opentelemetry.trace as trace_api import pytest from opentelemetry.proto.resource.v1.resource_pb2 import Resource as OTelProtoResource from opentelemetry.proto.trace.v1.trace_pb2 import Span as OTelProtoSpan from opentelemetry.proto.trace.v1.tra...
1,277
47,344
pyomo
pyomo/solvers/tests/mip/model.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...
24
795
probability
tensorflow_probability/python/internal/backend/numpy/debugging.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...
320
9,620
astropy
astropy/io/fits/util.py
.py
# Licensed under a 3-clause BSD style license - see PYFITS.rst import gzip import io import mmap import operator import os import signal import sys import tempfile import textwrap import threading import warnings import weakref from contextlib import contextmanager, suppress from functools import wraps import numpy a...
861
27,726
wandb
wandb/sdk/interface/interface.py
.py
from __future__ import annotations import abc import gzip import logging import time from collections.abc import Iterable from pathlib import Path from secrets import token_hex from typing import TYPE_CHECKING, Any from wandb import termwarn from wandb.proto import wandb_internal_pb2 as pb from wandb.proto import wan...
1,071
38,543
wandb
tests/system_tests/test_experimental/test_client_csharp.py
.py
import os import pathlib import subprocess import pytest @pytest.mark.timeout(300) def test_client_sharp(wandb_backend_spy): script_path = ( pathlib.Path(__file__).parent.parent.parent.parent / "experimental" / "client-csharp" / "examples" / "Basic" / "build_and_ru...
36
885
saleor
saleor/core/utils/validators.py
.py
import datetime from typing import Any import micawber from ...product import ProductMediaTypes from ..exceptions import UnsupportedMediaProviderException SUPPORTED_MEDIA_TYPES = { "photo": ProductMediaTypes.IMAGE, "video": ProductMediaTypes.VIDEO, } MEDIA_MAX_WIDTH = 1920 MEDIA_MAX_HEIGHT = 1080 def get_o...
53
1,621
sqlmap
tests/test_dialect.py
.py
#!/usr/bin/env python """ Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org) See the file 'LICENSE' for copying permission Per-DBMS query building (the injection-engine "dialect" layer). These pin the exact SQL that agent.* emits for each back-end. They are the regression net for queries.xml edits and fo...
113
4,415
mlflow
tests/tracking/request_header/test_default_request_header_provider.py
.py
from mlflow.tracking.request_header.default_request_header_provider import ( _DEFAULT_HEADERS, DefaultRequestHeaderProvider, ) def test_default_request_header_provider_in_context(): assert DefaultRequestHeaderProvider().in_context() def test_default_request_header_provider_request_headers(): request...
14
427
beam
sdks/python/apache_beam/io/components/rate_limiter.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...
250
8,766
wagtail
wagtail/utils/sendfile.py
.py
# Copied from django-sendfile 0.3.6 and tweaked to allow a backend to be passed # to sendfile() # See: https://github.com/johnsensible/django-sendfile/pull/33 import os.path from mimetypes import guess_type VERSION = (0, 3, 6) __version__ = ".".join(map(str, VERSION)) def _lazy_load(fn): _cached = [] def _d...
107
3,106
astropy
astropy/units/quantity.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ This module defines the `Quantity` object, which represents a number with some associated units. `Quantity` objects support operations like ordinary numbers, but will deal with unit conversions internally. """ import builtins import numbers import ope...
2,295
87,486
mlflow
mlflow/pyfunc/backend.py
.py
import ctypes import json import logging import os import pathlib import shlex import signal import subprocess import sys import warnings from pathlib import Path from mlflow import pyfunc from mlflow.exceptions import MlflowException from mlflow.models import FlavorBackend, Model, docker_utils from mlflow.models.dock...
518
20,832
coremltools
coremltools/test/optimize/coreml/test_post_training_quantization.py
.py
# Copyright (c) 2023, 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 import itertools import logging import platform import re import shutil import tempfile from contextlib ...
3,018
126,965
wandb
wandb/sdk/wandb_run.py
.py
from __future__ import annotations import contextlib import functools import glob import json import logging import numbers import os import pathlib import re import sys import threading import time import traceback from collections.abc import Callable, Mapping, Sequence from dataclasses import dataclass, field from d...
4,244
152,133
beam
sdks/python/apache_beam/examples/inference/vertex_ai_llm_text_classification.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...
146
5,285
mlflow
mlflow/entities/evaluation_dataset.py
.py
from __future__ import annotations import json from enum import Enum from typing import TYPE_CHECKING, Any from mlflow.data import Dataset from mlflow.data.evaluation_dataset_source import EvaluationDatasetSource from mlflow.data.pyfunc_dataset_mixin import PyFuncConvertibleDatasetMixin from mlflow.entities._mlflow_o...
637
23,852
sqlmap
tests/test_hql.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 HQL/JPQL (Hibernate ORM) injection engine. Mock oracles stand in for the HTTP/ORM layer so detection, fingerprinting, entity leakage, blind attrib...
299
12,579
pyomo
pyomo/contrib/parmest/tests/test_parmest.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...
3,467
131,852
pyfilesystem2
fs/__init__.py
.py
"""Python filesystem abstraction layer. """ __import__("pkg_resources").declare_namespace(__name__) # type: ignore from . import path from ._fscompat import fsdecode, fsencode from ._version import __version__ from .enums import ResourceType, Seek from .opener import open_fs __all__ = ["__version__", "ResourceType"...
13
341
probability
tensorflow_probability/python/experimental/sequential/ensemble_adjustment_kalman_filter_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...
142
5,300
saleor
saleor/graphql/order/tests/mutations/test_order_price_expiration.py
.py
import pytest from graphene import Node from .....order import OrderStatus from ....tests.utils import get_graphql_content DRAFT_ORDER_UPDATE_MUTATION = """ mutation draftUpdate( $id: ID! $voucher: ID! $customerNote: String $shippingAddress: AddressInput $billingAddress: AddressInput ) { draftOrderUpdate(...
294
6,736
hypercorn
src/hypercorn/asyncio/statsd.py
.py
from __future__ import annotations import asyncio from ..config import Config from ..statsd import StatsdLogger as Base class _DummyProto(asyncio.DatagramProtocol): pass class StatsdLogger(Base): def __init__(self, config: Config) -> None: super().__init__(config) self.address = config.sta...
26
738
pyomo
pyomo/common/errors.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...
269
8,713
textual
tests/snapshot_tests/snapshot_apps/key_display.py
.py
from textual.app import App, ComposeResult from textual.binding import Binding from textual.widgets import Footer class KeyDisplayApp(App): """Tests how keys are displayed in the Footer, and ensures that overriding the key_displays works as expected. Exercises both the built-in Textual key display replace...
37
1,135
beam
sdks/python/apache_beam/examples/matrix_power.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...
104
3,565
mlflow
mlflow/utils/autologging_utils/config.py
.py
import logging from dataclasses import dataclass from typing import Any from mlflow.utils.autologging_utils import AUTOLOGGING_INTEGRATIONS _logger = logging.getLogger(__name__) @dataclass class AutoLoggingConfig: """ A dataclass to hold common autologging configuration options. """ log_input_examp...
34
1,099
saleor
saleor/checkout/webhooks/list_shipping_methods.py
.py
import logging from typing import TYPE_CHECKING, Any, Union from django.conf import settings from promise import Promise from pydantic import ValidationError from ...shipping.interface import ShippingMethodData from ...webhook.event_types import WebhookEventSyncType from ...webhook.payloads import generate_checkout_p...
92
3,397
openvino
src/bindings/python/src/openvino/utils/types.py
.py
# -*- coding: utf-8 -*- # noqa: A005 # Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 """Functions related to converting between Python and numpy types and openvino types.""" import logging from typing import Union, Optional import numpy as np from openvino.exceptions import OVType...
178
5,311
pymc
tests/test_func_utils.py
.py
# Copyright 2024 - present The PyMC Developers # # 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...
123
4,034
saleor
saleor/webhook/tests/subscription_webhooks/test_create_deliveries_for_transaction_cancelation_requested.py
.py
import json from decimal import Decimal import graphene from django.utils import timezone from freezegun import freeze_time from ....core.prices import quantize_price from ....graphql.tests.queries import fragments from ....payment import TransactionAction, TransactionEventType from ....payment.interface import Trans...
197
6,382
probability
tensorflow_probability/python/experimental/fastgp/partial_lanczos.py
.py
# Copyright 2024 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...
282
9,933
onnx
onnx/reference/ops/op_optional.py
.py
# Copyright (c) ONNX Project Contributors # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations from onnx.helper import tensor_dtype_to_np_dtype from onnx.reference.op_run import OpRun class Optional(OpRun): def _run(self, x=None, type=None): # type: ignore[override] # noqa: A002 if...
19
601
saleor
saleor/product/interface.py
.py
from dataclasses import dataclass from decimal import Decimal @dataclass class VariantDiscountedPriceChange: variant_id: int channel_slug: str previous_price_amount: Decimal new_price_amount: Decimal currency: str @property def pk(self) -> tuple[int, str]: """Required by deferred ...
21
570
textual
docs/examples/guide/styles/dimensions04.py
.py
from textual.app import App, ComposeResult from textual.widgets import Static TEXT = """I must not fear. Fear is the mind-killer. Fear is the little-death that brings total obliteration. I will face my fear. I will permit it to pass over me and through me. And when it has gone past, I will turn the inner eye to see i...
31
884
saleor
saleor/graphql/webhook/subscription_payload.py
.py
import datetime import logging from collections.abc import Iterable from typing import Any from django.conf import settings from django.db import models from django.utils import timezone from django.utils.functional import SimpleLazyObject from graphql import get_default_backend, parse from graphql.error import GraphQ...
310
10,366
hydra
tests/test_apps/hydra_resolver_in_output_dir/my_app.py
.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved from omegaconf import DictConfig import hydra from hydra.core.hydra_config import HydraConfig @hydra.main() def my_app(_: DictConfig) -> None: print(HydraConfig.instance().get().runtime.output_dir) if __name__ == "__main__": my_app()
15
318
onnx
onnx/backend/test/case/node/tanh.py
.py
# Copyright (c) ONNX Project Contributors # # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations import numpy as np import onnx from onnx.backend.test.case.base import Base from onnx.backend.test.case.node import expect class Tanh(Base): @staticmethod def export() -> None: node =...
29
768
hatch
src/hatch/cli/dep/__init__.py
.py
import click from hatch.cli.env.lock import dependency_lock_click_options, run_dep_lock @click.group(short_help="Manage environment dependencies") def dep(): pass @dep.command("lock", short_help="Generate a lockfile for the active environment (`-e` / `HATCH_ENV`)") @dependency_lock_click_options @click.pass_ob...
256
10,698
jupytext
tests/unit/test_pep8.py
.py
from nbformat.v4.nbbase import new_code_cell, new_notebook from jupytext import read, reads, writes from jupytext.compare import compare from jupytext.pep8 import ( cell_ends_with_code, cell_ends_with_function_or_class, cell_has_code, next_instruction_is_function_or_class, pep8_lines_between_cells,...
210
5,189
scikit-bio
skbio/io/format/tests/test_taxdump.py
.py
# ---------------------------------------------------------------------------- # Copyright (c) 2013--, scikit-bio development team. # # Distributed under the terms of the Modified BSD License. # # The full license is in the file LICENSE.txt, distributed with this software. # --------------------------------------------...
174
8,055
conda
conda/cli/main_init.py
.py
# Copyright (C) 2012 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause """CLI implementation for `conda init`. Prepares the user's profile for running conda, and sets up the conda shell interface. """ from __future__ import annotations from argparse import SUPPRESS from logging import getLogger from typing impor...
191
6,192
onnxruntime
onnxruntime/test/testdata/CNTK/gen.py
.py
# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. import os import cntk as C import numpy as np import onnx from onnx import numpy_helper model_file = "model.onnx" data_dir = "test_data_set_0" def SaveTensorProto(file_path, variable, data, name): # noqa: N802 # ONNX...
277
9,218
confluent-kafka-python
src/confluent_kafka/schema_registry/avro.py
.py
#!/usr/bin/env python # -*- coding: utf-8 -*- # # Copyright 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 requi...
21
727
mlflow
tests/strands/conftest.py
.py
import pytest from opentelemetry import trace as otel_trace import mlflow from mlflow.tracing.provider import provider @pytest.fixture(autouse=True) def clear_autolog_state(reset_tracing): # Reset strands tracer singleton to clear cached tracer provider try: import strands.telemetry.tracer as strands...
32
1,013
pyomo
pyomo/contrib/gdpopt/tests/four_stage_dynamic_model.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...
395
12,740
mlflow
tests/dev/test_detect_flaky_tests.py
.py
import sys from pathlib import Path sys.path.insert(0, str(Path(__file__).resolve().parents[2] / "dev")) from detect_flaky_tests import gh_api_objects, parse_failing_tests # A captured pytest failure line as it appears in a raw GitHub Actions log: an ISO # timestamp prefix, ANSI SGR color codes around FAILED/the nod...
79
3,023
python-prompt-toolkit
examples/prompts/auto-completion/slow-completions.py
.py
#!/usr/bin/env python """ An example of how to deal with slow auto completion code. - Running the completions in a thread is possible by wrapping the `Completer` object in a `ThreadedCompleter`. This makes sure that the ``get_completions`` generator is executed in a background thread. For the `prompt` shortcut,...
105
2,649
python-prompt-toolkit
examples/prompts/system-clipboard-integration.py
.py
#!/usr/bin/env python """ Demonstration of a custom clipboard class. This requires the 'pyperclip' library to be installed. """ from prompt_toolkit import prompt from prompt_toolkit.clipboard.pyperclip import PyperclipClipboard if __name__ == "__main__": print("Emacs shortcuts:") print(" Press Control-Y to...
19
609
openvino
tests/e2e_tests/pipelines/pipeline_templates/comparators_template.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 from e2e_tests.common.decorators import wrap_ord_dict @wrap_ord_dict def classification_comparators(device, postproc=None, target_layers=None, precision=None, a_eps=None, r_eps=None, ntop=10): if post...
120
4,481
hydra
tests/test_examples/test_advanced_package_overrides.py
.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved from pathlib import Path from omegaconf import OmegaConf from hydra.test_utils.test_utils import chdir_hydra_root, run_python_script chdir_hydra_root() def test_advanced_package_override_simple(tmpdir: Path) -> None: cmd = [ "exampl...
34
1,067
beam
sdks/python/apache_beam/runners/dataflow/ptransform_overrides.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...
122
4,764
saleor
saleor/plugins/avatax/tests/conftest.py
.py
import os import pytest from ....account.models import Address from ...models import PluginConfiguration from .. import AvataxConfiguration from ..plugin import DeprecatedAvataxPlugin @pytest.fixture(scope="module") def vcr_config(): return { "filter_headers": [("Authorization", "Basic Og==")], } ...
980
36,752