Skip to content

Commit 64cde43

Browse files
authored
Merge pull request #464 from ExaWorks/fix-typeguard-version
typeguard update
2 parents 56cde86 + 5545e9c commit 64cde43

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
psutil~=5.9
22
pystache>=0.6.0
3-
typeguard~=2.12
3+
typeguard>=3.0.1
44
typing-compat
55
packaging~=24.0

src/psij/job_attributes.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from datetime import timedelta
44
from typing import Optional, Dict
55

6-
from typeguard import check_argument_types
6+
from typeguard import typechecked
77

88

99
logger = logging.getLogger(__name__)
@@ -16,6 +16,7 @@
1616
class JobAttributes(object):
1717
"""A class containing ancillary job information that describes how a job is to be run."""
1818

19+
@typechecked
1920
def __init__(self, duration: timedelta = timedelta(minutes=10),
2021
queue_name: Optional[str] = None, account: Optional[str] = None,
2122
reservation_id: Optional[str] = None,
@@ -49,8 +50,6 @@ def __init__(self, duration: timedelta = timedelta(minutes=10),
4950
5051
All constructor parameters are accessible as properties.
5152
"""
52-
assert check_argument_types()
53-
5453
self.account = account
5554
self.duration = duration
5655
self.queue_name = queue_name

src/psij/job_spec.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import pathlib
66
from typing import Dict, List, Optional, Union
77

8-
from typeguard import check_argument_types
8+
from typeguard import typechecked
99

1010
import psij.resource_spec
1111
import psij.job_attributes
@@ -36,6 +36,7 @@ def _to_env_dict(arg: Union[Dict[str, Union[str, int]], None]) -> Optional[Dict[
3636
class JobSpec(object):
3737
"""A class that describes the details of a job."""
3838

39+
@typechecked
3940
def __init__(self, executable: Optional[str] = None, arguments: Optional[List[str]] = None,
4041
# For some odd reason, and only in the constructor, if Path is used directly,
4142
# sphinx fails to find the class. Using Path in the getters and setters does not
@@ -129,8 +130,6 @@ def __init__(self, executable: Optional[str] = None, arguments: Optional[List[st
129130
the scheduler. In such a case, one must leave the `spec.directory` attribute empty and
130131
refer to files inside the job directory using relative paths.
131132
"""
132-
assert check_argument_types()
133-
134133
self._name = name
135134
self.executable = executable
136135
self.arguments = arguments

src/psij/resource_spec.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from abc import ABC, abstractmethod
22
from typing import Optional, List
33

4-
from typeguard import check_argument_types
4+
from typeguard import typechecked
55

66
from psij.exceptions import InvalidJobException
77

@@ -45,6 +45,7 @@ def get_instance(version: int) -> 'ResourceSpec':
4545
raise ValueError()
4646

4747

48+
@typechecked
4849
class ResourceSpecV1(ResourceSpec):
4950
"""This class implements V1 of the PSI/J resource specification."""
5051

@@ -81,8 +82,6 @@ def __init__(self, node_count: Optional[int] = None,
8182
8283
All constructor parameters are accessible as properties.
8384
"""
84-
assert check_argument_types()
85-
8685
self.node_count = node_count
8786
self.process_count = process_count
8887
self.processes_per_node = processes_per_node

tests/test_job_spec.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import os
22
from pathlib import Path
33

4+
from typeguard import suppress_type_checks
5+
46
import pytest
57

68
from psij import Job, JobExecutor, JobSpec
@@ -13,8 +15,9 @@ def _test_spec(spec: JobSpec) -> None:
1315

1416
def test_environment_types() -> None:
1517

16-
with pytest.raises(TypeError):
17-
_test_spec(JobSpec(executable='true', environment={1: 'foo'})) # type: ignore
18+
with suppress_type_checks():
19+
with pytest.raises(TypeError):
20+
_test_spec(JobSpec(executable='true', environment={1: 'foo'})) # type: ignore
1821

1922
with pytest.raises(TypeError):
2023
spec = JobSpec(executable='true')

0 commit comments

Comments
 (0)