Skip to content

Commit

Permalink
Fix new mypy warnings
Browse files Browse the repository at this point in the history
Some are from updated pyyaml typing and others are from mypy
0.990 being more careful with optional parameters.
  • Loading branch information
timj committed Nov 18, 2022
1 parent 4866da8 commit a4f207f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion python/lsst/pipe/base/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ class attribute must match a function argument name in the ``run``

dimensions: ClassVar[Set[str]]

def __init__(self, *, config: "PipelineTaskConfig" = None):
def __init__(self, *, config: "PipelineTaskConfig" | None = None):
self.inputs: Set[str] = set(self.inputs)
self.prerequisiteInputs: Set[str] = set(self.prerequisiteInputs)
self.outputs: Set[str] = set(self.outputs)
Expand Down
16 changes: 14 additions & 2 deletions python/lsst/pipe/base/pipelineIR.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,19 @@
from collections import Counter
from collections.abc import Iterable as abcIterable
from dataclasses import dataclass, field
from typing import Any, Dict, Generator, List, Literal, Mapping, MutableMapping, Optional, Set, Union
from typing import (
Any,
Dict,
Generator,
Hashable,
List,
Literal,
Mapping,
MutableMapping,
Optional,
Set,
Union,
)

import yaml
from lsst.resources import ResourcePath, ResourcePathExpression
Expand All @@ -46,7 +58,7 @@ class PipelineYamlLoader(yaml.SafeLoader):
found inside a pipeline file at a given scope.
"""

def construct_mapping(self, node: yaml.Node, deep: bool = False) -> Mapping[str, Any]:
def construct_mapping(self, node: yaml.MappingNode, deep: bool = False) -> dict[Hashable, Any]:
# do the call to super first so that it can do all the other forms of
# checking on this node. If you check the uniqueness of keys first
# it would save the work that super does in the case of a failure, but
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/pipe/base/tests/simpleQGraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def makeSimpleButler(root: str, run: str = "test", inMemory: bool = True) -> But


def populateButler(
pipeline: Pipeline, butler: Butler, datasetTypes: Dict[Optional[str], List[str]] = None
pipeline: Pipeline, butler: Butler, datasetTypes: Dict[Optional[str], List[str]] | None = None
) -> None:
"""Populate data butler with data needed for test.
Expand Down

0 comments on commit a4f207f

Please sign in to comment.