Update typing 03 (#48015)

This commit is contained in:
Marc Mueller
2021-03-17 21:46:07 +01:00
committed by GitHub
parent 6fb2e63e49
commit fabd73f08b
37 changed files with 417 additions and 379 deletions

View File

@@ -1,13 +1,15 @@
"""Merging of policies."""
from typing import Dict, List, Set, cast
from __future__ import annotations
from typing import cast
from .types import CategoryType, PolicyType
def merge_policies(policies: List[PolicyType]) -> PolicyType:
def merge_policies(policies: list[PolicyType]) -> PolicyType:
"""Merge policies."""
new_policy: Dict[str, CategoryType] = {}
seen: Set[str] = set()
new_policy: dict[str, CategoryType] = {}
seen: set[str] = set()
for policy in policies:
for category in policy:
if category in seen:
@@ -20,7 +22,7 @@ def merge_policies(policies: List[PolicyType]) -> PolicyType:
return new_policy
def _merge_policies(sources: List[CategoryType]) -> CategoryType:
def _merge_policies(sources: list[CategoryType]) -> CategoryType:
"""Merge a policy."""
# When merging policies, the most permissive wins.
# This means we order it like this:
@@ -34,7 +36,7 @@ def _merge_policies(sources: List[CategoryType]) -> CategoryType:
# merge each key in the source.
policy: CategoryType = None
seen: Set[str] = set()
seen: set[str] = set()
for source in sources:
if source is None:
continue