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
python-prompt-toolkit
examples/prompts/with-frames/frame-and-autocompletion.py
.py
#!/usr/bin/env python """ Example of a frame around a prompt input that has autocompletion and a bottom toolbar. """ from prompt_toolkit import prompt from prompt_toolkit.completion import WordCompleter from prompt_toolkit.filters import is_done animal_completer = WordCompleter( [ "alligator", "an...
64
1,269
astropy
astropy/io/ascii/connect.py
.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst # This file connects the readers/writers to the astropy.table.Table class import re from astropy.io import registry as io_registry # noqa: F401 from astropy.table import Table __all__ = [] def io_read(format, filename, **kwargs): from .ui import...
58
1,741
ipython
tests/conftest.py
.py
import builtins import inspect import os import pathlib import shutil import sys import types import pytest # Must register before it gets imported pytest.register_assert_rewrite("IPython.testing.tools") from IPython.testing import tools def get_ipython(): from IPython.terminal.interactiveshell import Terminal...
82
2,350
textual
src/textual/widgets/markdown.py
.py
from textual.widgets._markdown import ( Markdown, MarkdownBlock, MarkdownFence, MarkdownStream, MarkdownTableOfContents, TableOfContentsType, ) __all__ = [ "Markdown", "MarkdownBlock", "MarkdownFence", "MarkdownStream", "MarkdownTableOfContents", "TableOfContentsType", ]...
18
321
beam
sdks/python/apache_beam/transforms/external.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...
1,305
49,573
onnx
onnx/reference/ops/op_topk.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 topk_sorted_implementation(X, k, axis, largest): """See function `_kneighbors_reduce_func <https://github.com/scikit-learn/scikit...
111
4,040
pdm
src/pdm/models/working_set.py
.py
from __future__ import annotations import importlib.metadata as im import itertools import sys from collections import ChainMap from collections.abc import Iterable, Iterator, Mapping from pathlib import Path from pdm.utils import normalize_name default_context = im.DistributionFinder.Context() class EgglinkFinder...
95
3,360
mlflow
tests/tracing/display/test_ipython.py
.py
import json from collections import defaultdict from unittest.mock import Mock import pytest import mlflow from mlflow.tracing.display import ( IPythonTraceDisplayHandler, get_display_handler, get_notebook_iframe_html, ) from tests.tracing.helper import create_trace, skip_module_when_testing_trace_sdk s...
339
10,855
qutip
qutip/tests/core/test_eigen.py
.py
import scipy import numpy as np import pytest import qutip def is_eigen_set(oper, vals, vecs): for val, vec in zip(vals, vecs): assert abs(vec.norm() - 1) < 1e-13 assert abs(qutip.expect(oper, vec) - val) < 1e-13 @pytest.mark.parametrize(["sparse", 'dtype'], [ pytest.param(True, 'csr', id="s...
125
4,433
pyomo
pyomo/common/tests/import_ex.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...
16
574
probability
tensorflow_probability/python/experimental/auto_batching/stack_optimization_test.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...
91
3,159
coveragepy
tests/select_plugin.py
.py
# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 # For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt """ A pytest plugin to select tests by running an external command. See lab/pick.py for how to use pick.py to subset test suites. More about this: https://nedba...
36
1,221
mlflow
mlflow/tracing/otel/translation/open_inference.py
.py
""" Translation utilities for OpenInference semantic conventions. Reference: https://github.com/Arize-ai/openinference/blob/main/python/openinference-semantic-conventions/ """ from mlflow.entities.span import SpanType from mlflow.tracing.otel.translation.base import OtelSchemaTranslator class OpenInferenceTranslato...
55
2,644
pyomo
pyomo/contrib/gdpopt/GDPopt.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...
163
5,880
confluent-kafka-python
examples/share_consumer_commit_async.py
.py
#!/usr/bin/env python # # 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...
112
4,191
lemur
lemur/plugins/lemur_openssl/plugin.py
.py
""" .. module: lemur.plugins.lemur_openssl.plugin :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> """ import subprocess from flask import current_app from lemur.utils import m...
183
5,522
conda
conda/plugins/environment_specifiers/explicit.py
.py
# Copyright (C) 2012 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause """ **EXPERIMENTAL** Register the conda env spec for explicit files. """ from .. import hookimpl from ..types import CondaEnvironmentSpecifier, EnvironmentFormat @hookimpl def conda_environment_specifiers(): from ...env.specs.explicit imp...
23
626
sphinx
tests/roots/test-prolog/conf.py
.py
import sys from pathlib import Path sys.path.insert(0, str(Path.cwd().resolve())) extensions = ['prolog_markdown_parser'] rst_prolog = '*Hello world*.\n\n' rst_epilog = '\n\n*Good-bye world*.'
10
196
coremltools
deps/protobuf/update_version.py
.py
#!/usr/bin/env python # Usage: ./update_version.py <MAJOR>.<MINOR>.<MICRO> [<RC version>] # # Example: # ./update_version.py 3.7.1 2 # => Version will become 3.7.1-rc-2 (beta) # ./update_version.py 3.7.1 # => Version will become 3.7.1 (stable) import datetime import re import sys from xml.dom import minidom if le...
411
13,451
probability
tensorflow_probability/python/experimental/fastgp/fast_mtgp.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...
265
9,886
saleor
saleor/graphql/webhook/mutations/webhook_delete.py
.py
import graphene from django.core.exceptions import ValidationError from django.db import IntegrityError from django.db.models import Exists, OuterRef from ....app.models import App from ....permission.auth_filters import AuthorizationFilters from ....permission.enums import AppPermission from ....webhook import models...
74
2,707
coremltools
coremltools/proto/Scaler_pb2.py
.py
# -*- coding: utf-8 -*- # Generated by the protocol buffer compiler. DO NOT EDIT! # source: Scaler.proto """Generated protocol buffer code.""" from google.protobuf import descriptor as _descriptor from google.protobuf import descriptor_pool as _descriptor_pool from google.protobuf import message as _message from googl...
36
1,262
pyro
tests/nn/test_module.py
.py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 import io import math import warnings from typing import Callable, Iterable import pytest import torch from torch import nn from torch.distributions import constraints, transform_to import pyro import pyro.distributions as dist f...
1,087
35,470
mlflow
mlflow/store/artifact/sftp_artifact_repo.py
.py
import os import posixpath import sys import urllib.parse from contextlib import contextmanager from queue import Queue from mlflow.entities import FileInfo from mlflow.store.artifact.artifact_repo import ArtifactRepository # Based on: https://stackoverflow.com/a/58466685 def _put_r_for_windows(sftp, local_dir, remo...
143
5,538
wandb
wandb/sdk/lib/run_stopping.py
.py
"""Stopping a run if requested by wandb-core. A run can be stopped manually through the UI or automatically after a fatal upload error (if configured). "Stopping" a run means killing its script. """ from __future__ import annotations import asyncio import contextlib import time from collections.abc import Callable ...
118
3,458
pyomo
pyomo/core/kernel/variable.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...
453
14,556
probability
tensorflow_probability/python/layers/initializers.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...
127
4,499
loguru
tests/exceptions/source/ownership/catch_decorator.py
.py
import sys import _init from somelib import divide from loguru import logger def test(*, backtrace, colorize, diagnose): logger.remove() logger.add(sys.stderr, format="", colorize=colorize, backtrace=backtrace, diagnose=diagnose) @logger.catch def foo(): divide(1, 0) foo() test(backt...
25
572
mlflow
mlflow/genai/evaluation/context.py
.py
""" Introduces main Context class and the framework to specify different specialized contexts. """ import functools from abc import ABC, abstractmethod from typing import Callable, ParamSpec, TypeVar import mlflow from mlflow.tracking.context import registry as context_registry from mlflow.utils.mlflow_tags import ML...
146
4,020
python-prompt-toolkit
examples/full-screen/simple-demos/horizontal-align.py
.py
#!/usr/bin/env python """ Horizontal align demo with HSplit. """ from prompt_toolkit.application import Application from prompt_toolkit.formatted_text import HTML from prompt_toolkit.key_binding import KeyBindings from prompt_toolkit.layout.containers import ( HorizontalAlign, HSplit, VerticalAlign, VS...
210
7,273
hydra
hydra/_internal/callbacks.py
.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import warnings from typing import TYPE_CHECKING, Any, Optional from omegaconf import DictConfig, OmegaConf from hydra.types import TaskFunction if TYPE_CHECKING: from hydra.core.utils import JobReturn class Callbacks: def __init__(self...
66
2,310
probability
tensorflow_probability/python/bijectors/scale_matvec_lu_test.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...
202
8,169
pyro
tests/ops/test_packed.py
.py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 import itertools import random import pytest import torch from torch.distributions.utils import broadcast_all from pyro.ops import packed from tests.common import assert_equal EXAMPLE_DIMS = [ "".join(dims) for num_dims ...
75
2,259
clearml
clearml/utilities/plotlympl/mpltools.py
.py
""" Tools A module for converting from mpl language to plotly language. """ import math import warnings from typing import Tuple, Optional, Union, List, Any import matplotlib.dates from matplotlib import __version__ as matplotlib_version try: from matplotlib.patches import FancyBboxPatch except ImportError: ...
666
23,952
wagtail
wagtail/snippets/tests/test_api_v3/test_delete.py
.py
from django.contrib.auth.models import Permission from django.test import TestCase from django.urls import reverse from wagtail.api.v3.tests.base import TestV3Base from wagtail.test.testapp.models import Advert, UUIDSnippetWithRelations from wagtail.test.utils import WagtailTestUtils class TestV3SnippetDeleteBase(Te...
95
3,174
beam
learning/tour-of-beam/learning-content/io/big-query-io/table-schema/python-example/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"); y...
70
2,595
onnx
onnx/reference/ops/experimental/_op_run_experimental.py
.py
# Copyright (c) ONNX Project Contributors # # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations from onnx.reference.op_run import OpRun class OpRunExperimental(OpRun): op_domain = "experimental"
11
223
saleor
saleor/graphql/warehouse/mutations/warehouse_shipping_zone_unassign.py
.py
import graphene from ....permission.enums import ProductPermissions from ....warehouse import models from ...account.i18n import I18nMixin from ...core import ResolveInfo from ...core.mutations import DeprecatedModelMutation from ...core.types import NonNullList, WarehouseError from ...shipping.types import ShippingZo...
41
1,546
conda
conda/env/specs/requirements.py
.py
# Copyright (C) 2012 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause """Define requirements.txt spec.""" from __future__ import annotations import os from ...base.context import context from ...common.url import is_url from ...exceptions import CondaValueError, InvalidMatchSpec, PluginError from ...gateways.di...
95
3,119
onnxruntime
onnxruntime/test/testdata/test_shape_data_propagation_shape_mul_constantofshape.py
.py
# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # Negative regression fixture for the single-element guard in the elementwise # data-propagation consumers (Add/Sub/Mul/Div). # # Shape(X[3, 4]) produces a rank-1, MULTI-element value [3, 4]. The elementwise # custom data pro...
51
2,263
onnxruntime
onnxruntime/test/python/transformers/test_onnx_utils.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------- import unittest import numpy from onnx import ModelProto, TensorProto, ...
39
1,886
pyro
pyro/distributions/softlaplace.py
.py
# Copyright Contributors to the Pyro project. # SPDX-License-Identifier: Apache-2.0 import math import torch from torch.distributions import constraints from torch.distributions.utils import broadcast_all from .torch_distribution import TorchDistribution class SoftLaplace(TorchDistribution): """ Smooth dis...
75
2,471
luigi
luigi/contrib/mysqldb.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...
243
8,325
pyro
pyro/infer/elbo.py
.py
# Copyright (c) 2017-2019 Uber Technologies, Inc. # SPDX-License-Identifier: Apache-2.0 import logging import warnings from abc import ABCMeta, abstractmethod import torch import pyro import pyro.poutine as poutine from pyro.infer.util import is_validation_enabled from pyro.poutine.util import prune_subsample_sites ...
240
9,572
probability
tensorflow_probability/python/experimental/sts_gibbs/spike_and_slab.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...
804
37,298
textual
tests/test_arrange.py
.py
import pytest from textual._arrange import TOP_Z, arrange from textual._context import active_app from textual.app import App from textual.geometry import NULL_OFFSET, Region, Size, Spacing from textual.layout import WidgetPlacement from textual.widget import Widget async def test_arrange_empty(): container = Wi...
128
3,608
mlflow
dev/clint/tests/rules/test_missing_docstring_param.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.missing_docstring_param import MissingDocstringParam def test_missing_docstring_param(index: SymbolIndex) -> None: code = ''' def bad_function(param1: ...
91
2,542
pyro
pyro/contrib/epidemiology/models.py
.py
# Copyright Contributors to the Pyro project. # SPDX-License-Identifier: Apache-2.0 import re import torch from torch.nn.functional import pad import pyro import pyro.distributions as dist from .compartmental import CompartmentalModel from .distributions import binomial_dist, infection_dist class SimpleSIRModel(C...
1,286
51,173
astropy
astropy/timeseries/periodograms/lombscargle/implementations/slow_impl.py
.py
import numpy as np def lombscargle_slow( t, y, dy, frequency, normalization="standard", fit_mean=True, center_data=True ): """Lomb-Scargle Periodogram. This is a pure-python implementation of the original Lomb-Scargle formalism (e.g. [1]_, [2]_), with the addition of the floating mean (e.g. [3]_) ...
120
3,721
mlflow
tests/gateway/schemas/test_embeddings.py
.py
import pydantic import pytest from mlflow.gateway.schemas import embeddings def test_embeddings_request(): embeddings.RequestPayload(**{"input": "text"}) embeddings.RequestPayload(**{"input": ""}) embeddings.RequestPayload(**{"input": ["prompt"]}) embeddings.RequestPayload(**{"input": "text", "extra"...
37
1,231
onnxruntime
tools/python/util/ort_format_model/operator_type_usage_processors.py
.py
# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. from __future__ import annotations import json from abc import ABC, abstractmethod import ort_flatbuffers_py.fbs as fbs from .types import FbsTypeInfo, value_name_to_typestr def _create_op_key(domain: str, optype: str): ...
654
26,379
pyomo
pyomo/core/kernel/suffix.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...
350
11,506
conda
tests/gateways/test_repodata_shards.py
.py
# Copyright (C) 2012 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause """ Test bytes cache used for sharded repodata. """ from pathlib import Path from conda.gateways.repodata import FORMAT_JSON, FORMAT_SHARDS, RepodataCache def test_bytes_cache(tmp_path: Path): """ Test caching bytes in a separate ".m...
46
1,459
onnxruntime
onnxruntime/test/python/transformers/test_parity_gelu.py
.py
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- """ Belo...
243
7,935
scikit-optimize
skopt/sampler/base.py
.py
from collections import defaultdict class InitialPointGenerator(object): def generate(self, dimensions, n_samples, random_state=None): raise NotImplemented def set_params(self, **params): """ Set the parameters of this initial point generator. Parameters ---------- ...
29
689
hatch
src/hatch/env/lockers/__init__.py
.py
from hatch.env.lockers.interface import LockerInterface from hatch.env.lockers.pip import PipLocker from hatch.env.lockers.uv import UvLocker __all__ = ["LockerInterface", "PipLocker", "UvLocker"]
6
198
mlflow
tests/demo/conftest.py
.py
import pytest from mlflow.demo.base import BaseDemoGenerator, DemoFeature, DemoResult from mlflow.demo.registry import DemoRegistry class StubGenerator(BaseDemoGenerator): name = DemoFeature.TRACES def __init__(self, version: int = 1): self._version = version self.generate_called = False ...
74
1,718
sphinx
sphinx/util/_uri.py
.py
from __future__ import annotations from urllib.parse import parse_qsl, quote_plus, urlencode, urlsplit, urlunsplit def encode_uri(uri: str) -> str: scheme, netloc, url, query, fragment = urlsplit(uri) netloc = netloc.encode('idna').decode('ascii') url = quote_plus(url.encode(), '/') query = urlencode...
17
540
gunicorn
tests/test_http2_async_connection.py
.py
# -*- coding: utf-8 - # # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. """Tests for async HTTP/2 server connection.""" import asyncio import pytest from unittest import mock from io import BytesIO # Check if h2 is available for integration tests try: import...
1,017
34,178
astropy
astropy/timeseries/periodograms/lombscargle/core.py
.py
"""Main Lomb-Scargle Implementation.""" 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 . import _statistics from .implementations import available_methods, lombscargle from .imp...
767
28,267
biopython
Bio/UniGene/__init__.py
.py
# Copyright 2006 by Sean Davis, National Cancer Institute, NIH. # 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 # pack...
336
12,738
marshmallow
src/marshmallow/constants.py
.py
import typing EXCLUDE: typing.Final = "exclude" INCLUDE: typing.Final = "include" RAISE: typing.Final = "raise" class _Missing: def __bool__(self): return False def __copy__(self): return self def __deepcopy__(self, _): return self def __repr__(self): return "<marsh...
26
415
onnxruntime
onnxruntime/python/torch_cpp_extensions/ort_torch_ext/__init__.py
.py
import threading from functools import wraps import torch # noqa: F401 from onnxruntime.capi import _pybind_state as _C from .aten_op_executor import execute_aten_operator_address, is_tensor_argument_address def run_once_aten_op_executor(f): """ Decorator to run a function only once. :param f: functio...
38
1,213
sqlmap
lib/core/revision.py
.py
#!/usr/bin/env python """ Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org) See the file 'LICENSE' for copying permission """ import os import re import subprocess from lib.core.common import openFile from lib.core.convert import getText def getRevisionNumber(): """ Returns abbreviated commit h...
63
1,800
conda
conda/env/installers/pip.py
.py
# Copyright (C) 2012 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause """Pip-flavored installer.""" import os import os.path as op from logging import getLogger from ...auxlib.compat import Utf8NamedTemporaryFile from ...env.pip_util import get_pip_installed_packages, get_pip_workdir, pip_subprocess from ...repo...
74
2,678
readthedocs.org
dockerfiles/settings/web.py
.py
from .docker_compose import DockerBaseSettings class WebDevSettings(DockerBaseSettings): DONT_HIT_DB = False WebDevSettings.load_settings(__name__)
8
155
mlflow
mlflow/langchain/api_request_parallel_processor.py
.py
# Based ons: https://github.com/openai/openai-cookbook/blob/6df6ceff470eeba26a56de131254e775292eac22/examples/api_request_parallel_processor.py # Several changes were made to make it work with MLflow. # Currently, only chat completion is supported. """ API REQUEST PARALLEL PROCESSOR Using the LangChain API to process...
334
13,118
cvxpy
cvxpy/tests/test_canon_sign.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 ...
56
2,064
saleor
saleor/graphql/csv/mutations/__init__.py
.py
from .export_gift_cards import ExportGiftCards from .export_products import ExportProducts from .export_voucher_codes import ExportVoucherCodes __all__ = ["ExportGiftCards", "ExportProducts", "ExportVoucherCodes"]
6
215
openvino
tests/e2e_tests/common/logger.py
.py
# Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 import base64 import inspect import logging import os import re import weakref from datetime import datetime from typing import cast, Union from collections.abc import Generator from e2e_tests.common import config SEPARATOR = "=" * 20...
301
11,847
kafka
tests/kafkatest/tests/tools/trogdor_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 use ...
100
4,508
sphinx
sphinx/util/docstrings.py
.py
"""Utilities for docstring processing.""" from __future__ import annotations import re import sys from docutils.parsers.rst.states import Body field_list_item_re = re.compile(Body.patterns['field_marker']) def separate_metadata(s: str | None) -> tuple[str | None, dict[str, str]]: """Separate docstring into me...
89
2,944
cvxpy
cvxpy/reductions/dgp2dcp/canonicalizers/log_canon.py
.py
from cvxpy.atoms.elementwise.log import log def log_canon(expr, args): return log(args[0]), []
6
101
sphinx
tests/test_ext_autodoc/test_ext_autodoc_autofunction.py
.py
"""Test the autodoc extension. This tests mainly the Documenters; the auto directives are tested in a test source file translated by test_build. """ from __future__ import annotations import pytest from tests.test_ext_autodoc.autodoc_util import do_autodoc pytestmark = pytest.mark.usefixtures('inject_autodoc_root_...
202
5,231
gunicorn
tests/workers/test_gevent_import_order.py
.py
# # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. """ Test for gevent worker compatibility with concurrent.futures import order. Issue: https://github.com/benoitc/gunicorn/issues/3482 Discussion: https://github.com/benoitc/gunicorn/discussions/3481 Gist: https://...
362
14,137
beam
sdks/python/apache_beam/testing/benchmarks/cloudml/pipelines/workflow.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
7,913
qutip
qutip/tests/core/data/test_ptrace.py
.py
from . import test_mathematics as testing import numpy as np import scipy.linalg import pytest from qutip import data from qutip.core.data import CSR, Dense, Dia class TestPtrace(testing.UnaryOpMixin): def op_numpy(self, matrix, dims, sel): sel.sort() ndims = len(dims) dkeep = [dims[x] for...
110
3,571
probability
tensorflow_probability/python/mcmc/dual_averaging_step_size_adaptation.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...
645
30,386
openvino
src/bindings/python/src/openvino/utils/reduction.py
.py
# -*- coding: utf-8 -*- # Copyright (C) 2018-2026 Intel Corporation # SPDX-License-Identifier: Apache-2.0 from typing import Optional from collections.abc import Iterable from openvino import Node def get_reduction_axes(node: Node, reduction_axes: Optional[Iterable[int]]) -> Iterable[int]: """Get reduction axes...
27
854
biopython
Bio/SearchIO/ExonerateIO/_base.py
.py
# Copyright 2012 by Wibowo Arindrarto. 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. """Bio.SearchIO abstrac...
568
21,071
pyfilesystem2
fs/error_tools.py
.py
"""Tools for managing OS errors. """ from __future__ import print_function, unicode_literals import sys import typing import errno import platform from contextlib import contextmanager from six import reraise from . import errors if typing.TYPE_CHECKING: from typing import Iterator, Optional, Text, Type, Union...
118
3,824
coremltools
coremltools/test/optimize/torch/pruning/pruning_utils.py
.py
# Copyright (c) 2024, 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 os import numpy as np import torch import coremltools.test.optimize.torch.utils as utils ba...
88
3,011
loguru
loguru/_better_exceptions.py
.py
import builtins import inspect import io import keyword import linecache import os import re import sys import sysconfig import tokenize import traceback if sys.version_info >= (3, 11): def is_exception_group(exc): return isinstance(exc, ExceptionGroup) else: try: from exceptiongroup import E...
586
21,974
wagtail
wagtail/admin/views/pages/bulk_actions/delete.py
.py
from django.conf import settings from django.urls import reverse from django.utils.translation import gettext_lazy as _ from django.utils.translation import ngettext from wagtail.admin.views.bulk_action.mixins import ReferenceIndexMixin from wagtail.admin.views.pages.bulk_actions.page_bulk_action import PageBulkAction...
80
3,279
returns
tests/test_primitives/test_container/test_base_container/test_pickle_backward_deserialization.py
.py
import pickle # noqa: S403 from returns.primitives.container import BaseContainer def test_pickle_backward_deserialization(): """Test that BaseContainer can be deserialized from 0.19.0 and earlier.""" # BaseContainer(1) serialized as of 0.19.0 serialized_container = ( b'\x80\x04\x958\x00\x00\x00...
15
539
saleor
saleor/core/postgres.py
.py
import logging from django.conf import settings from django.contrib.postgres.search import ( CombinedSearchVector, SearchVector, SearchVectorCombinable, ) from django.db.models import Expression, Value from .utils.text import strip_accents logger = logging.getLogger(__name__) class NoValidationSearchVe...
153
5,850
pyomo
pyomo/gdp/plugins/multiple_bigm.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,073
47,140
funcy
tests/test_colls.py
.py
from collections.abc import Iterator from collections import defaultdict, namedtuple from itertools import chain, count import pytest from whatever import _ from funcy.colls import * # Utilities def eq(a, b): return type(a) is type(b) and a == b \ and (a.default_factory == b.default_factory if isinstance(...
357
10,391
coveragepy
tests/test_plugins.py
.py
# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 # For details: https://github.com/coveragepy/coveragepy/blob/main/NOTICE.txt """Tests for plugins.""" from __future__ import annotations import inspect import io import math import os.path from collections.abc import Iterable from typin...
1,334
46,201
beam
sdks/python/apache_beam/examples/cookbook/custom_ptransform.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...
132
3,969
conda
conda/gateways/connection/adapters/ftp.py
.py
# Copyright (C) 2012 Cory Benfield # SPDX-License-Identifier: Apache-2.0 """Defines FTP transport adapter for CondaSession (requests.Session). Taken from requests-ftp (https://github.com/Lukasa/requests-ftp/blob/master/requests_ftp/ftp.py). Licensed under the Apache License, Version 2.0 (the "License"); you may not u...
279
9,554
black
tests/data/cases/comment_in_subscript_annotation.py
.py
# Regression test for https://github.com/psf/black/issues/4733. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: list[ # bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb int ] = [] # Original (non-minimized) snippet from the issue report. def foo(): possibly_redundant_lowlevel_checkpoints: list[ # pyright: ignore[reportUnkn...
26
812
saleor
saleor/account/tests/test_throttling.py
.py
import datetime import logging from unittest.mock import patch import pytest from django.core.exceptions import ValidationError from django.utils import timezone from freezegun import freeze_time from ...tests import race_condition from ..error_codes import AccountErrorCode from ..throttling import ( MAX_DELAY, ...
409
13,554
cvxpy
cvxpy/tests/test_constraints.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...
965
39,723
sqlmap
thirdparty/bottle/bottle.py
.py
#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import print_function """ Bottle is a fast and simple micro-framework for small web applications. It offers request dispatching (Routes) with URL parameter support, templates, a built-in HTTP Server and adapters for many third party WSGI/HTTP-server and temp...
4,679
179,955
cvxpy
cvxpy/tests/test_complex_dpp.py
.py
""" Copyright 2024 - 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, sof...
192
7,424
kombu
kombu/mixins.py
.py
"""Mixins.""" from __future__ import annotations import socket from contextlib import contextmanager from functools import partial from itertools import count from time import sleep from .common import ignore_errors from .log import get_logger from .messaging import Consumer, Producer from .utils.compat import neste...
304
9,701
saleor
saleor/graphql/shop/mutations/return_settings_update.py
.py
import graphene from django.core.exceptions import ValidationError from ....permission.enums import SitePermissions from ....site.error_codes import ReturnSettingsErrorCode from ...core import ResolveInfo from ...core.descriptions import ADDED_IN_323 from ...core.doc_category import DOC_CATEGORY_SHOP from ...core.muta...
76
2,600
readthedocs.org
readthedocs/doc_builder/loader.py
.py
"""Lookup tables for builders and backends.""" from importlib import import_module from django.conf import settings # Managers mkdocs = import_module(settings.MKDOCS_BACKEND) sphinx = import_module(settings.SPHINX_BACKEND) BUILDER_BY_NAME = { # Possible HTML Builders "sphinx": sphinx.HtmlBuilder, "sphi...
28
690
beam
sdks/python/apache_beam/internal/azure/auth.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...
84
2,745