Skip to content

Commit 6b6f0ae

Browse files
authored
Merge pull request #290 from altheaden/lint-with-ruff
Switch linting to use `ruff` and lint all existing code
2 parents 4cc984b + df2960b commit 6b6f0ae

File tree

167 files changed

+7460
-4124
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

167 files changed

+7460
-4124
lines changed

.flake8

Lines changed: 0 additions & 16 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@ repos:
99
- id: trailing-whitespace
1010
- id: end-of-file-fixer
1111

12-
# Can run individually with `pre-commit run isort --all-files`
13-
- repo: https://github.com/PyCQA/isort
14-
rev: 6.0.1
15-
hooks:
16-
- id: isort
17-
1812
# Can run individually with `flynt [file]` or `flynt [source]`
1913
- repo: https://github.com/ikamensh/flynt
2014
rev: '1.0.1'
@@ -23,15 +17,18 @@ repos:
2317
args: ["--fail-on-change", "--verbose"]
2418
require_serial: true
2519

26-
# Can run individually with `pre-commit run flake8 --all-files`
27-
# Need to use flake8 GitHub mirror due to CentOS git issue with GitLab
28-
# https://github.com/pre-commit/pre-commit/issues/1206
29-
- repo: https://github.com/pycqa/flake8
30-
rev: 7.1.2
20+
- repo: https://github.com/astral-sh/ruff-pre-commit
21+
rev: v0.9.9
3122
hooks:
32-
- id: flake8
33-
args: ["--config=.flake8"]
34-
additional_dependencies: [flake8-isort]
23+
# Sort the imports
24+
- id: ruff
25+
name: ruff-sort-imports
26+
args: [--select, I, --fix]
27+
# Run the linter.
28+
- id: ruff
29+
args: [--fix]
30+
# Run the formatter.
31+
- id: ruff-format
3532

3633
# Can run individually with `pre-commit run mypy --all-files`
3734
- repo: https://github.com/pre-commit/mirrors-mypy
@@ -41,8 +38,3 @@ repos:
4138
args: ["--config=pyproject.toml", "--show-error-codes"]
4239
verbose: true
4340
additional_dependencies: ['types-requests']
44-
45-
# https://pre-commit.ci/#configuration
46-
ci:
47-
autofix_prs: false
48-
autoupdate_schedule: monthly

configure_polaris_envs.py

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,21 @@ def main():
3030

3131
env_name = 'polaris_bootstrap'
3232

33-
source_activation_scripts = \
34-
f'source {conda_base}/etc/profile.d/conda.sh'
33+
source_activation_scripts = f'source {conda_base}/etc/profile.d/conda.sh'
3534

3635
activate_base = f'{source_activation_scripts} && conda activate'
3736

38-
activate_install_env = \
39-
f'{source_activation_scripts} && ' \
40-
f'conda activate {env_name}'
37+
activate_install_env = (
38+
f'{source_activation_scripts} && conda activate {env_name}'
39+
)
4140
os.makedirs(name='deploy_tmp/logs', exist_ok=True)
4241

4342
if args.verbose:
4443
logger = None
4544
else:
46-
logger = get_logger(log_filename='deploy_tmp/logs/prebootstrap.log',
47-
name=__name__)
45+
logger = get_logger(
46+
log_filename='deploy_tmp/logs/prebootstrap.log', name=__name__
47+
)
4848

4949
# install miniforge if needed
5050
install_miniforge(conda_base, activate_base, logger)
@@ -58,20 +58,29 @@ def main():
5858
mache_version = config.get('deploy', 'mache')
5959
packages = f'{packages} "mache={mache_version}"'
6060

61-
_setup_install_env(env_name, activate_base, args.use_local, logger,
62-
args.recreate, conda_base, packages)
61+
_setup_install_env(
62+
env_name,
63+
activate_base,
64+
args.use_local,
65+
logger,
66+
args.recreate,
67+
conda_base,
68+
packages,
69+
)
6370

6471
if local_mache:
6572
print('Clone and install local mache\n')
66-
commands = f'{activate_install_env} && ' \
67-
f'rm -rf deploy_tmp/build_mache && ' \
68-
f'mkdir -p deploy_tmp/build_mache && ' \
69-
f'cd deploy_tmp/build_mache && ' \
70-
f'git clone -b {args.mache_branch} ' \
71-
f'[email protected]:{args.mache_fork}.git mache && ' \
72-
f'cd mache && ' \
73-
f'conda install -y --file spec-file.txt && ' \
74-
f'python -m pip install --no-deps --no-build-isolation .'
73+
commands = (
74+
f'{activate_install_env} && '
75+
f'rm -rf deploy_tmp/build_mache && '
76+
f'mkdir -p deploy_tmp/build_mache && '
77+
f'cd deploy_tmp/build_mache && '
78+
f'git clone -b {args.mache_branch} '
79+
f'[email protected]:{args.mache_fork}.git mache && '
80+
f'cd mache && '
81+
f'conda install -y --file spec-file.txt && '
82+
f'python -m pip install --no-deps --no-build-isolation .'
83+
)
7584

7685
check_call(commands, logger=logger)
7786

@@ -105,8 +114,9 @@ def _get_config(config_file):
105114
return config
106115

107116

108-
def _setup_install_env(env_name, activate_base, use_local, logger, recreate,
109-
conda_base, packages):
117+
def _setup_install_env(
118+
env_name, activate_base, use_local, logger, recreate, conda_base, packages
119+
):
110120
"""
111121
Setup a conda environment for installing polaris
112122
"""
@@ -124,8 +134,10 @@ def _setup_install_env(env_name, activate_base, use_local, logger, recreate,
124134
else:
125135
print('Updating conda environment for installing polaris\n')
126136
conda_command = 'install'
127-
commands = f'{activate_base} && ' \
128-
f'conda {conda_command} -y -n {env_name} {channels} {packages}'
137+
commands = (
138+
f'{activate_base} && '
139+
f'conda {conda_command} -y -n {env_name} {channels} {packages}'
140+
)
129141

130142
check_call(commands, logger=logger)
131143

@@ -137,8 +149,10 @@ def _bootstrap(activate_install_env, source_path, local_conda_build):
137149

138150
print('Creating the polaris conda environment\n')
139151
bootstrap_command = f'{source_path}/deploy/bootstrap.py'
140-
command = f'{activate_install_env} && ' \
141-
f'{bootstrap_command} {" ".join(sys.argv[1:])}'
152+
command = (
153+
f'{activate_install_env} && '
154+
f'{bootstrap_command} {" ".join(sys.argv[1:])}'
155+
)
142156
if local_conda_build is not None:
143157
command = f'{command} --local_conda_build {local_conda_build}'
144158
check_call(command)

0 commit comments

Comments
 (0)