Skip to content

Commit 3ad46e7

Browse files
committed
Remove restriction on flake8 since it leads to a conflict with Sphinx.
The reason why flak8 was complaining is because of the removal of support for `# type: xyz` style declarations. So convert all those to proper type declarations.
1 parent 8d222c7 commit 3ad46e7

File tree

10 files changed

+28
-28
lines changed

10 files changed

+28
-28
lines changed

requirements-dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# Testing / QA
88
-r requirements-tests.txt
99
mypy >=0.931
10-
flake8==5.0.4
10+
flake8
1111
flake8-docstrings
1212
autopep8
1313
types-requests

src/psij/_plugins.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ def _register_plugin(desc: Descriptor, root_path: str, type: str,
6262
if desc.name not in store:
6363
store[desc.name] = []
6464
existing = store[desc.name]
65-
entry = _VersionEntry(desc.version, desc_path=desc.path, plugin_path=mod_path,
66-
ecls=cls, exc=exc) # type: _VersionEntry[T]
65+
entry: _VersionEntry[T] = _VersionEntry(desc.version, desc_path=desc.path,
66+
plugin_path=mod_path, ecls=cls, exc=exc)
6767
# check if an object with this version already exists
6868
index = bisect_left(existing, entry)
6969
if index != len(existing) and existing[index].version == desc.version:

src/psij/executors/batch/batch_scheduler_executor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ def _attrs_to_mustache(job: Job) -> Dict[str, Union[object, List[Dict[str, objec
3333
if not job.spec.attributes or not job.spec.attributes._custom_attributes:
3434
return {}
3535

36-
r = {} # type: Dict[str, Union[object, List[Dict[str, object]]]]
36+
r: Dict[str, Union[object, List[Dict[str, object]]]] = {}
3737

3838
for k, v in job.spec.attributes._custom_attributes.items():
3939
ks = k.split('.', maxsplit=1)
4040
if len(ks) == 2:
4141
if ks[0] not in r:
42-
r[ks[0]] = [] # type[List[Dict[str, object]]
42+
r[ks[0]] = []
4343
cast(List[Dict[str, object]], r[ks[0]]).append({'key': ks[1], 'value': v})
4444
else:
4545
r[k] = v
@@ -563,7 +563,7 @@ def __init__(self, name: str, config: BatchSchedulerExecutorConfig,
563563
self.config = config
564564
self.executor = executor
565565
# native_id -> job
566-
self._jobs = {} # type: Dict[str, List[Job]]
566+
self._jobs: Dict[str, List[Job]] = {}
567567
# counts consecutive errors while invoking qstat or equivalent
568568
self._poll_error_count = 0
569569
self._jobs_lock = RLock()

src/psij/executors/local.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ class _ProcessEntry(ABC):
2323
def __init__(self, job: Job, executor: 'LocalJobExecutor', launcher: Optional[Launcher]):
2424
self.job = job
2525
self.executor = executor
26-
self.exit_code = None # type: Optional[int]
27-
self.done_time = None # type: Optional[float]
28-
self.out = None # type: Optional[str]
26+
self.exit_code: Optional[int] = None
27+
self.done_time: Optional[float] = None
28+
self.out: Optional[str] = None
2929
self.kill_flag = False
30-
self.process = None # type: Optional[subprocess.Popen[bytes]]
30+
self.process: Optional[subprocess.Popen[bytes]] = None
3131
self.launcher = launcher
3232

3333
@abstractmethod
@@ -80,7 +80,7 @@ def kill(self) -> None:
8080
def poll(self) -> Tuple[Optional[int], Optional[str]]:
8181
try:
8282
assert self.process
83-
ec = self.process.wait(timeout=0) # type: Optional[int]
83+
ec: Optional[int] = self.process.wait(timeout=0)
8484
if ec is None:
8585
return 0, None
8686
else:
@@ -105,7 +105,7 @@ def _get_env(spec: JobSpec) -> Optional[Dict[str, str]]:
105105

106106

107107
class _ProcessReaper(threading.Thread):
108-
_instance = None # type: _ProcessReaper
108+
_instance: Optional['_ProcessReaper'] = None
109109
_lock = threading.RLock()
110110

111111
@classmethod
@@ -118,7 +118,7 @@ def get_instance(cls: Type['_ProcessReaper']) -> '_ProcessReaper':
118118

119119
def __init__(self) -> None:
120120
super().__init__(name='Local Executor Process Reaper', daemon=True)
121-
self._jobs = {} # type: Dict[Job, _ProcessEntry]
121+
self._jobs: Dict[Job, _ProcessEntry] = {}
122122
self._lock = threading.RLock()
123123

124124
def register(self, entry: _ProcessEntry) -> None:
@@ -137,7 +137,7 @@ def run(self) -> None:
137137
time.sleep(_REAPER_SLEEP_TIME)
138138

139139
def _check_processes(self) -> None:
140-
done = [] # type: List[_ProcessEntry]
140+
done: List[_ProcessEntry] = []
141141
for entry in self._jobs.values():
142142
if entry.kill_flag:
143143
entry.kill()

src/psij/job.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ def __init__(self, spec: Optional[JobSpec] = None) -> None:
4545
self._id = _generate_id()
4646
self._status = JobStatus(JobState.NEW)
4747
# need indirect ref to avoid a circular reference
48-
self.executor = None # type: Optional['psij.JobExecutor']
48+
self.executor: Optional['psij.JobExecutor'] = None
4949
# allow the native ID to be anything and do the string conversion in the getter; there's
5050
# no point in storing integers as strings.
51-
self._native_id = None # type: Optional[object]
52-
self._cb = None # type: Optional[JobStatusCallback]
51+
self._native_id: Optional[object] = None
52+
self._cb: Optional[JobStatusCallback] = None
5353
self._status_cv = threading.Condition()
5454
if logger.isEnabledFor(logging.DEBUG):
5555
logger.debug('New Job: {}'.format(self))

src/psij/job_executor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
class JobExecutor(ABC):
2222
"""An abstract base class for all JobExecutor implementations."""
2323

24-
_executors = {} # type: Dict[str, List[_VersionEntry['JobExecutor']]]
24+
_executors: Dict[str, List[_VersionEntry['JobExecutor']]] = {}
2525

2626
def __init__(self, url: Optional[str] = None,
2727
config: Optional[JobExecutorConfig] = None):
@@ -40,9 +40,9 @@ def __init__(self, url: Optional[str] = None,
4040
assert config
4141
self.config = config
4242
# _cb is not thread-safe; changing it while jobs are running could lead to badness
43-
self._cb = None # type: Optional[JobStatusCallback]
43+
self._cb: Optional[JobStatusCallback] = None
4444
self._launchers_lock = RLock()
45-
self._launchers = {} # type: Dict[str, Launcher]
45+
self._launchers: Dict[str, Launcher] = {}
4646

4747
@property
4848
def name(self) -> str:

src/psij/job_launcher.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
class Launcher(ABC):
1313
"""An abstract base class for all launchers."""
1414

15-
_launchers = {} # type: Dict[str, List[_VersionEntry['Launcher']]]
15+
_launchers: Dict[str, List[_VersionEntry['Launcher']]] = {}
1616
DEFAULT_LAUNCHER_NAME = 'single'
1717

1818
def __init__(self, config: Optional[JobExecutorConfig] = None) -> None:

src/psij/job_state.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class JobState(bytes, Enum):
1111

1212
def __new__(cls, index: int, order: int, name: str, final: bool) -> 'JobState': # noqa: D102
1313
# This is used internally to allow enum initialization with multiple parameters
14-
obj = bytes.__new__(cls) # type: 'JobState'
14+
obj: 'JobState' = bytes.__new__(cls)
1515
obj._value_ = index
1616
obj._order = order
1717
obj._name = name
@@ -20,9 +20,9 @@ def __new__(cls, index: int, order: int, name: str, final: bool) -> 'JobState':
2020

2121
def __init__(self, *args: object) -> None: # noqa: D107
2222
# this is only here to declare the types of the properties
23-
self._order = self._order # type: int
24-
self._name = self._name # type: str
25-
self._final = self._final # type: bool
23+
self._order: int = self._order
24+
self._name: str = self._name
25+
self._final: bool = self._final
2626

2727
NEW = (0, 0, 'NEW', False)
2828
"""

src/psij/launcher.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
class Launcher(ABC):
1313
"""An abstract base class for all launchers."""
1414

15-
_launchers = {} # type: Dict[str, List[_VersionEntry['Launcher']]]
15+
_launchers: Dict[str, List[_VersionEntry['Launcher']]] = {}
1616
DEFAULT_LAUNCHER_NAME = 'single'
1717

1818
def __init__(self, config: Optional[JobExecutorConfig] = None) -> None:

tests/executor_test_params.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ def __init__(self, spec: str, custom_attributes: Optional[Dict[str, object]] = N
1818
spec_l = re.split(':', spec, maxsplit=2)
1919
self.executor = spec_l[0]
2020
if len(spec_l) > 1:
21-
self.launcher = spec_l[1] # type: Optional[str]
21+
self.launcher: Optional[str] = spec_l[1]
2222
else:
2323
self.launcher = None
2424
if len(spec_l) == 3:
25-
self.url = spec_l[2] # type: Optional[str]
25+
self.url: Optional[str] = spec_l[2]
2626
else:
2727
self.url = None
2828

0 commit comments

Comments
 (0)