本文整理匯總了Python中typing.AbstractSet方法的典型用法代碼示例。如果您正苦於以下問題:Python typing.AbstractSet方法的具體用法?Python typing.AbstractSet怎麽用?Python typing.AbstractSet使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類typing
的用法示例。
在下文中一共展示了typing.AbstractSet方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: import typing [as 別名]
# 或者: from typing import AbstractSet [as 別名]
def __init__(self,
servers: AbstractSet[Remote],
key_store: MasterKeyStore,
interval: datetime.timedelta,
key_type: Type[PKey]=RSAKey,
bits: Optional[int]=None,
start: bool=True) -> None:
super().__init__()
self.servers = servers
self.key_store = key_store
self.interval = interval
self.key_type = key_type
self.bits = bits
self.terminated = threading.Event()
if self.start:
self.start()
示例2: skip_for_variants
# 需要導入模塊: import typing [as 別名]
# 或者: from typing import AbstractSet [as 別名]
def skip_for_variants(meta: MetaData, variant_keys: AbstractSet[str]) -> bool:
"""Check if the recipe uses any given variant keys
Args:
meta: Variant MetaData object
Returns:
True if any variant key from variant_keys is used
"""
# This is the same behavior as in
# conda_build.metadata.Metadata.get_hash_contents but without leaving out
# "build_string_excludes" (python, r_base, etc.).
dependencies = set(meta.get_used_vars())
trim_build_only_deps(meta, dependencies)
return not dependencies.isdisjoint(variant_keys)
示例3: comment
# 需要導入模塊: import typing [as 別名]
# 或者: from typing import AbstractSet [as 別名]
def comment(self, problems: Mapping[ni_abc.Status, AbstractSet[str]]) -> Optional[str]:
"""Add an appropriate comment relating to the CLA status."""
if not problems:
return None
comments_url = self.request['pull_request']['comments_url']
problem_messages: Dict[str, str] = defaultdict(str)
for status, usernames in problems.items():
problem_messages[status.name] = self._problem_message_template(
status
).format(
', '.join(f"@{username}" for username in usernames)
)
message = NO_CLA_TEMPLATE.format_map(problem_messages)
await self._gh.post(comments_url, data={'body': message})
return message
示例4: update
# 需要導入模塊: import typing [as 別名]
# 或者: from typing import AbstractSet [as 別名]
def update(self, problems: Mapping[ni_abc.Status, AbstractSet[str]]) -> None:
if self.event == PullRequestEvent.opened:
await self.set_label(problems)
await self.comment(problems)
elif self.event == PullRequestEvent.unlabeled:
# The assumption is that a PR will almost always go from no CLA to
# being cleared, so don't bug the user with what will probably
# amount to a repeated message about lacking a CLA.
await self.set_label(problems)
elif self.event == PullRequestEvent.synchronize:
current_label = await self.current_label()
if not problems:
if current_label != CLA_OK:
await self.remove_label()
elif current_label != NO_CLA:
await self.remove_label()
# Since there is a chance a new person was added to a PR
# which caused the change in status, a comment on how to
# resolve the CLA issue is probably called for.
await self.comment(problems)
else: # pragma: no cover
# Should never be reached.
msg = 'do not know how to update a PR for {}'.format(self.event)
raise RuntimeError(msg)
示例5: qubit_set
# 需要導入模塊: import typing [as 別名]
# 或者: from typing import AbstractSet [as 別名]
def qubit_set(self) -> Optional[AbstractSet['cirq.Qid']]:
"""Returns a set or frozenset of qubits on the device, if possible.
Returns:
If the device has a finite set of qubits, then a set or frozen set
of all qubits on the device is returned.
If the device has no well defined finite set of qubits (e.g.
`cirq.UnconstrainedDevice` has this property), then `None` is
returned.
"""
# Compatibility hack to work with devices that were written before this
# method was defined.
for name in ['qubits', '_qubits']:
if hasattr(self, name):
val = getattr(self, name)
if callable(val):
val = val()
return frozenset(val)
# Default to the qubits being unknown.
return None
示例6: create_elevator_database
# 需要導入模塊: import typing [as 別名]
# 或者: from typing import AbstractSet [as 別名]
def create_elevator_database(world_list: WorldList,
areas_to_not_change: AbstractSet[int],
) -> Tuple[Elevator, ...]:
"""
Creates a tuple of Elevator objects, exclude those that belongs to one of the areas provided.
:param world_list:
:param areas_to_not_change: Set of asset_id of Areas whose teleporters are to be ignored
:return:
"""
return tuple(
Elevator(node.teleporter_instance_id,
world.world_asset_id,
area.area_asset_id,
node.default_connection.world_asset_id,
node.default_connection.area_asset_id)
for world, area, node in world_list.all_worlds_areas_nodes
if isinstance(node, TeleporterNode) and node.editable and area.area_asset_id not in areas_to_not_change
)
示例7: test_all
# 需要導入模塊: import typing [as 別名]
# 或者: from typing import AbstractSet [as 別名]
def test_all(self):
from typing import __all__ as a
# Just spot-check the first and last of every category.
self.assertIn('AbstractSet', a)
self.assertIn('ValuesView', a)
self.assertIn('cast', a)
self.assertIn('overload', a)
if hasattr(contextlib, 'AbstractContextManager'):
self.assertIn('ContextManager', a)
# Check that io and re are not exported.
self.assertNotIn('io', a)
self.assertNotIn('re', a)
# Spot-check that stdlib modules aren't exported.
self.assertNotIn('os', a)
self.assertNotIn('sys', a)
# Check that Text is defined.
self.assertIn('Text', a)
# Check previously missing classes.
self.assertIn('SupportsBytes', a)
self.assertIn('SupportsComplex', a)
示例8: get_subset_for_channels
# 需要導入模塊: import typing [as 別名]
# 或者: from typing import AbstractSet [as 別名]
def get_subset_for_channels(self, channels: AbstractSet[ChannelID]) -> 'Waveform':
"""Get a waveform that only describes the channels contained in `channels`.
Args:
channels: A channel set the return value should confine to.
Raises:
KeyError: If `channels` is not a subset of the waveform's defined channels.
Returns:
A waveform with waveform.defined_channels == `channels`
"""
if not channels <= self.defined_channels:
raise KeyError('Channels not defined on waveform: {}'.format(channels))
if channels == self.defined_channels:
return self
return self.unsafe_get_subset_for_channels(channels=channels)
示例9: is_fulfilled
# 需要導入模塊: import typing [as 別名]
# 或者: from typing import AbstractSet [as 別名]
def is_fulfilled(self, parameters: Mapping[str, Any], volatile: AbstractSet[str] = frozenset()) -> bool:
"""
Args:
parameters: These parameters are checked.
volatile: For each of these parameters a warning is raised if they appear in a constraint
Raises:
:class:`qupulse.parameter_scope.ParameterNotProvidedException`: if a parameter is missing
Warnings:
ConstrainedParameterIsVolatileWarning: if a constrained parameter is volatile
"""
affected_parameters = self.affected_parameters
if not affected_parameters.issubset(parameters.keys()):
raise ParameterNotProvidedException((affected_parameters-parameters.keys()).pop())
for parameter in volatile & affected_parameters:
warnings.warn(ConstrainedParameterIsVolatileWarning(parameter_name=parameter, constraint=self))
return numpy.all(self._expression.evaluate_in_scope(parameters))
示例10: prepare_field
# 需要導入模塊: import typing [as 別名]
# 或者: from typing import AbstractSet [as 別名]
def prepare_field(cls, field: ModelField) -> None:
env_names: Union[List[str], AbstractSet[str]]
env = field.field_info.extra.get('env')
if env is None:
if field.has_alias:
warnings.warn(
'aliases are no longer used by BaseSettings to define which environment variables to read. '
'Instead use the "env" field setting. '
'See https://pydantic-docs.helpmanual.io/usage/settings/#environment-variable-names',
FutureWarning,
)
env_names = {cls.env_prefix + field.name}
elif isinstance(env, str):
env_names = {env}
elif isinstance(env, (set, frozenset)):
env_names = env
elif sequence_like(env):
env_names = list(env)
else:
raise TypeError(f'invalid field env: {env!r} ({display_as_type(env)}); should be string, list or set')
if not cls.case_sensitive:
env_names = env_names.__class__(n.lower() for n in env_names)
field.field_info.extra['env_names'] = env_names
示例11: fx_bitbucket_group_slugs
# 需要導入模塊: import typing [as 別名]
# 或者: from typing import AbstractSet [as 別名]
def fx_bitbucket_group_slugs(request) -> typing.AbstractSet[str]:
try:
slugs = request.config.getoption('--bitbucket-group-slugs')
except ValueError:
slugs = None
if not slugs:
skip('--bitbucket-group-slugs is not provided; skipped')
return {slug.strip() for slug in slugs.split()}
示例12: test_list_groups
# 需要導入模塊: import typing [as 別名]
# 或者: from typing import AbstractSet [as 別名]
def test_list_groups(fx_bitbucket_identity: Identity,
fx_bitbucket_team_username: str,
fx_bitbucket_group_slugs: typing.AbstractSet[str]):
org = BitbucketTeam('', '', fx_bitbucket_team_username)
groups = org.list_groups(fx_bitbucket_identity)
assert groups == fx_bitbucket_group_slugs
示例13: fx_github_team_slugs
# 需要導入模塊: import typing [as 別名]
# 或者: from typing import AbstractSet [as 別名]
def fx_github_team_slugs(request) -> typing.AbstractSet[str]:
try:
slugs = request.config.getoption('--github-team-slugs')
except ValueError:
slugs = None
if not slugs:
skip('--github-team-slugs is not provided; skipped')
return {slug.strip() for slug in slugs.split()}
示例14: test_list_groups
# 需要導入模塊: import typing [as 別名]
# 或者: from typing import AbstractSet [as 別名]
def test_list_groups(fx_github_identity: Identity, fx_github_org_login: str,
fx_github_team_slugs: typing.AbstractSet[str]):
org = GitHubOrganization('', '', fx_github_org_login)
groups = org.list_groups(fx_github_identity)
assert groups == fx_github_team_slugs
示例15: list_keys
# 需要導入模塊: import typing [as 別名]
# 或者: from typing import AbstractSet [as 別名]
def list_keys(self, identity: Identity) -> AbstractSet[PKey]:
try:
keys = self.identities[identity]
except KeyError:
return frozenset()
return frozenset(keys)