Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mypy v0.920 update #299

Merged
merged 3 commits into from
Dec 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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