Skip to content

Commit

Permalink
mypy v0.920 update (microsoft#299)
Browse files Browse the repository at this point in the history
  • Loading branch information
ashnair1 authored Dec 17, 2021
1 parent a8b2a8e commit e2ff524
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ repos:
additional_dependencies: ["toml"]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.910
rev: v0.920
hooks:
- id: mypy
args: [--strict, --ignore-missing-imports, --show-error-codes]
Expand Down
2 changes: 1 addition & 1 deletion benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def main(args: argparse.Namespace) -> None:
dataloader = DataLoader(
dataset,
batch_size=args.batch_size,
sampler=sampler, # type: ignore[arg-type]
sampler=sampler,
num_workers=args.num_workers,
collate_fn=stack_samples,
)
Expand Down
5 changes: 2 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,8 @@ style =
# pydocstyle 6.1+ required for pyproject.toml support
pydocstyle[toml]>=6.1
tests =
# mypy 0.900+ required for pyproject.toml support, 0.920 has a decorator bug:
# https://github.com/python/mypy/issues/11763
mypy>=0.900,!=0.920
# mypy 0.900+ required for pyproject.toml support
mypy>=0.900
# nbmake 0.1+ required to fix path_source bug
nbmake>=0.1
# pytest 6+ required for pyproject.toml support
Expand Down
4 changes: 2 additions & 2 deletions torchgeo/datasets/idtrees.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,15 +334,15 @@ def _load(self, root: str) -> Tuple[List[str], Dict[int, Dict[str, Any]], Any]:
else:
directory = os.path.join(root, self.task)
if self.task == "task1":
geoms = None # type: ignore[assignment]
geoms = None
labels = None
else:
geoms = self._load_geometries(directory)
labels = None

images = glob.glob(os.path.join(directory, "RemoteSensing", "RGB", "*.tif"))

return images, geoms, labels
return images, geoms, labels # type: ignore[return-value]

def _load_labels(self, directory: str) -> Any:
"""Load the csv files containing the labels.
Expand Down
4 changes: 3 additions & 1 deletion torchgeo/datasets/oscd.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,9 @@ def _load_image(self, paths: Sequence[str]) -> Tensor:
for path in paths:
with Image.open(path) as img:
images.append(np.array(img))
array = np.stack(images, axis=0).astype(np.int_)
array: Array = np.stack(images, axis=0).astype( # type: ignore[type-arg]
np.int_
)
tensor: Tensor = torch.from_numpy(array) # type: ignore[attr-defined]
return tensor

Expand Down

0 comments on commit e2ff524

Please sign in to comment.