Skip to content

Commit da51f80

Browse files
committed
Use correct linter settings
1 parent b5c9101 commit da51f80

20 files changed

+605
-388
lines changed

cmdstanpy/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ def _cleanup_tmpdir() -> None:
3737
from .utils import (
3838
cmdstan_path,
3939
cmdstan_version,
40+
disable_logging,
41+
enable_logging,
4042
install_cmdstan,
4143
set_cmdstan_path,
4244
set_make_env,
4345
show_versions,
4446
write_stan_json,
45-
enable_logging,
46-
disable_logging,
4747
)
4848

4949
__all__ = [

cmdstanpy/cmdstan_args.py

Lines changed: 256 additions & 227 deletions
Large diffs are not rendered by default.

cmdstanpy/compilation.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ def validate_stanc_opts(self) -> None:
165165
del self._stanc_options[deprecated]
166166
else:
167167
get_logger().warning(
168-
'compiler option "%s" is deprecated and should not be used',
168+
'compiler option "%s" is deprecated and should '
169+
'not be used',
169170
deprecated,
170171
)
171172
for key, val in self._stanc_options.items():
@@ -224,7 +225,8 @@ def validate_cpp_opts(self) -> None:
224225
val = self._cpp_options[key]
225226
if not isinstance(val, int) or val < 0:
226227
raise ValueError(
227-
f'{key} must be a non-negative integer value, found {val}.'
228+
f'{key} must be a non-negative integer '
229+
f'value, found {val}.'
228230
)
229231

230232
def validate_user_header(self) -> None:
@@ -234,7 +236,8 @@ def validate_user_header(self) -> None:
234236
"""
235237
if self._user_header != "":
236238
if not (
237-
os.path.exists(self._user_header) and os.path.isfile(self._user_header)
239+
os.path.exists(self._user_header)
240+
and os.path.isfile(self._user_header)
238241
):
239242
raise ValueError(
240243
f"User header file {self._user_header} cannot be found"
@@ -272,7 +275,9 @@ def add(self, new_opts: "CompilerOptions") -> None: # noqa: disable=Q000
272275
else:
273276
for key, val in new_opts.stanc_options.items():
274277
if key == 'include-paths':
275-
if isinstance(val, Iterable) and not isinstance(val, str):
278+
if isinstance(val, Iterable) and not isinstance(
279+
val, str
280+
):
276281
for path in val:
277282
self.add_include_path(str(path))
278283
else:
@@ -337,7 +342,9 @@ def compose(self, filename_in_msg: Optional[str] = None) -> list[str]:
337342
return opts
338343

339344

340-
def src_info(stan_file: str, compiler_options: CompilerOptions) -> dict[str, Any]:
345+
def src_info(
346+
stan_file: str, compiler_options: CompilerOptions
347+
) -> dict[str, Any]:
341348
"""
342349
Get source info for Stan program file.
343350
@@ -525,7 +532,9 @@ def format_stan_file(
525532
else:
526533
raise ValueError(
527534
"Invalid arguments passed for current CmdStan"
528-
+ " version({})\n".format(cmdstan_version() or "Unknown")
535+
+ " version({})\n".format(
536+
cmdstan_version() or "Unknown"
537+
)
529538
+ "--canonicalize requires 2.29 or higher"
530539
)
531540
else:

cmdstanpy/install_cmdstan.py

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,9 @@ def latest_version() -> str:
110110
print('retry ({}/5)'.format(i + 1))
111111
sleep(1)
112112
continue
113-
raise CmdStanRetrieveError('Cannot connect to CmdStan github repo.') from e
113+
raise CmdStanRetrieveError(
114+
'Cannot connect to CmdStan github repo.'
115+
) from e
114116
content = json.loads(response.decode('utf-8'))
115117
tag = content['tag_name']
116118
match = re.search(r'v?(.+)', tag)
@@ -286,18 +288,26 @@ def build(verbose: bool = False, progress: bool = True, cores: int = 1) -> None:
286288
raise CmdStanInstallError(f'Command "make build" failed\n{str(e)}')
287289
if not os.path.exists(os.path.join('bin', 'stansummary' + EXTENSION)):
288290
raise CmdStanInstallError(
289-
f'bin/stansummary{EXTENSION} not found, please rebuild or report a bug!'
291+
f'bin/stansummary{EXTENSION} not found, please rebuild or '
292+
'report a bug!'
290293
)
291294
if not os.path.exists(os.path.join('bin', 'diagnose' + EXTENSION)):
292295
raise CmdStanInstallError(
293-
f'bin/stansummary{EXTENSION} not found, please rebuild or report a bug!'
296+
f'bin/stansummary{EXTENSION} not found, please rebuild or '
297+
'report a bug!'
294298
)
295299

296300
if is_windows():
297301
# Add tbb to the $PATH on Windows
298-
libtbb = os.path.join(os.getcwd(), 'stan', 'lib', 'stan_math', 'lib', 'tbb')
302+
libtbb = os.path.join(
303+
os.getcwd(), 'stan', 'lib', 'stan_math', 'lib', 'tbb'
304+
)
299305
os.environ['PATH'] = ';'.join(
300-
list(OrderedDict.fromkeys([libtbb] + os.environ.get('PATH', '').split(';')))
306+
list(
307+
OrderedDict.fromkeys(
308+
[libtbb] + os.environ.get('PATH', '').split(';')
309+
)
310+
)
301311
)
302312

303313

@@ -408,9 +418,8 @@ def install_version(
408418
)
409419
if overwrite and os.path.exists('.'):
410420
print(
411-
'Overwrite requested, remove existing build of version {}'.format(
412-
cmdstan_version
413-
)
421+
'Overwrite requested, remove existing build '
422+
'of version {}'.format(cmdstan_version)
414423
)
415424
clean_all(verbose)
416425
print('Rebuilding version {}'.format(cmdstan_version))
@@ -477,9 +486,9 @@ def retrieve_version(version: str, progress: bool = True) -> None:
477486
for i in range(6): # always retry to allow for transient URLErrors
478487
try:
479488
if progress and progbar.allow_show_progress():
480-
progress_hook: Optional[Callable[[int, int, int], None]] = (
481-
wrap_url_progress_hook()
482-
)
489+
progress_hook: Optional[
490+
Callable[[int, int, int], None]
491+
] = wrap_url_progress_hook()
483492
else:
484493
progress_hook = None
485494
file_tmp, _ = urllib.request.urlretrieve(
@@ -488,13 +497,14 @@ def retrieve_version(version: str, progress: bool = True) -> None:
488497
break
489498
except urllib.error.HTTPError as e:
490499
raise CmdStanRetrieveError(
491-
'HTTPError: {}\nVersion {} not available from github.com.'.format(
492-
e.code, version
493-
)
500+
'HTTPError: {}\nVersion {} not available from '
501+
'github.com.'.format(e.code, version)
494502
) from e
495503
except urllib.error.URLError as e:
496504
print(
497-
'Failed to download CmdStan version {} from github.com'.format(version)
505+
'Failed to download CmdStan version {} from github.com'.format(
506+
version
507+
)
498508
)
499509
print(e)
500510
if i < 5:
@@ -640,7 +650,8 @@ def parse_cmdline_args() -> dict[str, Any]:
640650
'--interactive',
641651
'-i',
642652
action='store_true',
643-
help="Ignore other arguments and run the installation in " + "interactive mode",
653+
help="Ignore other arguments and run the installation in "
654+
+ "interactive mode",
644655
)
645656
parser.add_argument(
646657
'--version',

cmdstanpy/install_cxx_toolchain.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,7 @@ def get_url(version: str) -> str:
244244
if version == '4.0':
245245
# pylint: disable=line-too-long
246246
if IS_64BITS:
247-
url = (
248-
'https://cran.r-project.org/bin/windows/Rtools/rtools40-x86_64.exe' # noqa: disable=E501
249-
)
247+
url = 'https://cran.r-project.org/bin/windows/Rtools/rtools40-x86_64.exe' # noqa: disable=E501
250248
else:
251249
url = 'https://cran.r-project.org/bin/windows/Rtools/rtools40-i686.exe' # noqa: disable=E501
252250
elif version == '3.5':
@@ -311,7 +309,9 @@ def run_rtools_install(args: dict[str, Any]) -> None:
311309
else:
312310
if os.path.exists(toolchain_folder):
313311
shutil.rmtree(toolchain_folder, ignore_errors=False)
314-
retrieve_toolchain(toolchain_folder + EXTENSION, url, progress=progress)
312+
retrieve_toolchain(
313+
toolchain_folder + EXTENSION, url, progress=progress
314+
)
315315
install_version(
316316
toolchain_folder,
317317
toolchain_folder + EXTENSION,
@@ -325,7 +325,9 @@ def run_rtools_install(args: dict[str, Any]) -> None:
325325
and (version in ('4.0', '4', '40'))
326326
):
327327
if os.path.exists(
328-
os.path.join(toolchain_folder, 'mingw64', 'bin', 'mingw32-make.exe')
328+
os.path.join(
329+
toolchain_folder, 'mingw64', 'bin', 'mingw32-make.exe'
330+
)
329331
):
330332
print('mingw32-make.exe already installed')
331333
else:

0 commit comments

Comments
 (0)