Skip to content

Commit b6b254d

Browse files
authored
Merge pull request #161 from talagayev/add_ruff
Transition to `Ruff` Formatter
2 parents e8f3148 + bb116f5 commit b6b254d

27 files changed

+888
-1445
lines changed

.github/workflows/CI-CD.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,20 @@ jobs:
3232
run: |
3333
pip install .
3434
35-
- name: Install linter and formatter
35+
- name: Install linting tools
3636
run: |
37-
python -m pip install shyaml flake8 black black-nb flake8-nb
37+
python -m pip install shyaml flake8 black black-nb flake8-nb ruff
38+
39+
- name: Check Ruff formatting
40+
id: ruff-format
41+
continue-on-error: true
42+
run: |
43+
ruff format --check .
44+
45+
- name: Provide Ruff formatting guidance
46+
if: steps.ruff-format.outcome == 'failure'
47+
run: |
48+
echo "::warning::Ruff formatting issues detected. Run 'ruff format .' locally to apply formatting fixes."
3849
3950
- name: Run black formatter
4051
run: |

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ talagayev
2727
- Fixes numpy error in due current incompatbility with parmed (2025-10-19, PR #160)
2828

2929
### Changed
30-
30+
- Transition to `Ruff` linting with `Black` style (2025-10-20, PR #161)
31+
-
3132
## Version 1.1.1
3233

3334
### Authors

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ OpenMMDL @ Molecular Design Lab
1010
| **Availability** | [![Condaforge][badge_conda_forge]][url_conda_forge] ![Docker][badge_docker]|
1111
| **Workflows** | ![CI_CD][badge_ci_cd] ![CodeQL][badge_codeql]|
1212
| **Documentation** | [![docs][badge_docs]][url_docs] [![codecov][badge_codecov]][url_codecov]|
13-
| **Dependencies** | [![rdkit][badge_rdkit]][url_rdkit] [![mdanalysis][badge_mda]][url_mda] [![Code style: black][badge_black]][url_black]|
13+
| **Style** | [![Code style: black][badge_black]][url_black]|
14+
| **Linting** | [![ruff][badge_ruff]][url_ruff]|
15+
| **Dependencies** | [![rdkit][badge_rdkit]][url_rdkit] [![mdanalysis][badge_mda]][url_mda]|
1416
| **License** | [![License: GPL v2][badge_license]][url_license]|
1517

1618

@@ -199,7 +201,7 @@ run visualization_pymol.py
199201
openmdl_visualization PATH_TO_interacting_waters.pdb, modulePATH_TO_clouds.json
200202
```
201203
## Copyright
202-
Copyright (c) 2022, Valerij Talagayev, Yu Chen, Niklas Piet Doering & Leon Obendorf (Wolber lab)
204+
Copyright (c) 2022, Valerij Talagayev, Yu Chen, Niklas Piet Doering & Leon Obendorf (Wolber lab)
203205

204206
### Citation
205207
If you use OpenMMDL in your research, please cite the following [paper](https://doi.org/10.1021/acs.jcim.4c02158).
@@ -231,6 +233,7 @@ This Project is based on the
231233
[badge_mda]: https://img.shields.io/badge/powered%20by-MDAnalysis-orange.svg?logoWidth=16&logo=data:image/x-icon;base64,AAABAAEAEBAAAAEAIAAoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJD+XwCY/fEAkf3uAJf97wGT/a+HfHaoiIWE7n9/f+6Hh4fvgICAjwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACT/yYAlP//AJ///wCg//8JjvOchXly1oaGhv+Ghob/j4+P/39/f3IAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJH8aQCY/8wAkv2kfY+elJ6al/yVlZX7iIiI8H9/f7h/f38UAAAAAAAAAAAAAAAAAAAAAAAAAAB/f38egYF/noqAebF8gYaagnx3oFpUUtZpaWr/WFhY8zo6OmT///8BAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgICAn46Ojv+Hh4b/jouJ/4iGhfcAAADnAAAA/wAAAP8AAADIAAAAAwCj/zIAnf2VAJD/PAAAAAAAAAAAAAAAAICAgNGHh4f/gICA/4SEhP+Xl5f/AwMD/wAAAP8AAAD/AAAA/wAAAB8Aov9/ALr//wCS/Z0AAAAAAAAAAAAAAACBgYGOjo6O/4mJif+Pj4//iYmJ/wAAAOAAAAD+AAAA/wAAAP8AAABhAP7+FgCi/38Axf4fAAAAAAAAAAAAAAAAiIiID4GBgYKCgoKogoB+fYSEgZhgYGDZXl5e/m9vb/9ISEjpEBAQxw8AAFQAAAAAAAAANQAAADcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAjo6Mb5iYmP+cnJz/jY2N95CQkO4pKSn/AAAA7gAAAP0AAAD7AAAAhgAAAAEAAAAAAAAAAACL/gsAkv2uAJX/QQAAAAB9fX3egoKC/4CAgP+NjY3/c3Nz+wAAAP8AAAD/AAAA/wAAAPUAAAAcAAAAAAAAAAAAnP4NAJL9rgCR/0YAAAAAfX19w4ODg/98fHz/i4uL/4qKivwAAAD/AAAA/wAAAP8AAAD1AAAAGwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALGxsVyqqqr/mpqa/6mpqf9KSUn/AAAA5QAAAPkAAAD5AAAAhQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADkUFBSuZ2dn/3V1df8uLi7bAAAATgBGfyQAAAA2AAAAMwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB0AAADoAAAA/wAAAP8AAAD/AAAAWgC3/2AAnv3eAJ/+dgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA9AAAA/wAAAP8AAAD/AAAA/wAKDzEAnP3WAKn//wCS/OgAf/8MAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIQAAANwAAADtAAAA7QAAAMAAABUMAJn9gwCe/e0Aj/2LAP//AQAAAAAAAAAA
232234
[badge_black]: https://img.shields.io/badge/code%20style-black-000000.svg
233235
[badge_license]: https://img.shields.io/badge/License-MIT-blue.svg
236+
[badge_ruff]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
234237
[badge_docker]: https://img.shields.io/badge/Docker-2496ED?logo=docker&logoColor=fff
235238

236239
[url_latest_release]: https://github.com/wolberlab/openmmdl/releases
@@ -242,4 +245,5 @@ This Project is based on the
242245
[url_rdkit]: https://www.rdkit.org/
243246
[url_mda]: https://www.mdanalysis.org
244247
[url_black]: https://github.com/psf/black
248+
[url_ruff]: https://github.com/astral-sh/ruff
245249
[url_license]: https://opensource.org/licenses/MIT

devtools/scripts/create_conda_env.py

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
import subprocess as sp
77
from tempfile import TemporaryDirectory
88
from contextlib import contextmanager
9+
910
# YAML imports
1011
try:
1112
import yaml # PyYAML
13+
1214
loader = yaml.safe_load
1315
except ImportError:
1416
try:
@@ -17,19 +19,22 @@
1719
try:
1820
# Load Ruamel YAML from the base conda environment
1921
from importlib import util as import_util
20-
CONDA_BIN = os.path.dirname(os.environ['CONDA_EXE'])
21-
ruamel_yaml_path = glob.glob(os.path.join(CONDA_BIN, '..',
22-
'lib', 'python*.*', 'site-packages',
23-
'ruamel_yaml', '__init__.py'))[0]
22+
23+
CONDA_BIN = os.path.dirname(os.environ["CONDA_EXE"])
24+
ruamel_yaml_path = glob.glob(
25+
os.path.join(CONDA_BIN, "..", "lib", "python*.*", "site-packages", "ruamel_yaml", "__init__.py")
26+
)[0]
2427
# Based on importlib example, but only needs to load_module since its the whole package, not just
2528
# a module
26-
spec = import_util.spec_from_file_location('ruamel_yaml', ruamel_yaml_path)
29+
spec = import_util.spec_from_file_location("ruamel_yaml", ruamel_yaml_path)
2730
yaml = spec.loader.load_module()
2831
except (KeyError, ImportError, IndexError):
29-
raise ImportError("No YAML parser could be found in this or the conda environment. "
30-
"Could not find PyYAML or Ruamel YAML in the current environment, "
31-
"AND could not find Ruamel YAML in the base conda environment through CONDA_EXE path. "
32-
"Environment not created!")
32+
raise ImportError(
33+
"No YAML parser could be found in this or the conda environment. "
34+
"Could not find PyYAML or Ruamel YAML in the current environment, "
35+
"AND could not find Ruamel YAML in the base conda environment through CONDA_EXE path. "
36+
"Environment not created!"
37+
)
3338
loader = yaml.YAML(typ="safe").load # typ="safe" avoids odd typing on output
3439

3540

@@ -46,13 +51,10 @@ def temp_cd():
4651

4752

4853
# Args
49-
parser = argparse.ArgumentParser(description='Creates a conda environment from file for a given Python version.')
50-
parser.add_argument('-n', '--name', type=str,
51-
help='The name of the created Python environment')
52-
parser.add_argument('-p', '--python', type=str,
53-
help='The version of the created Python environment')
54-
parser.add_argument('conda_file',
55-
help='The file for the created Python environment')
54+
parser = argparse.ArgumentParser(description="Creates a conda environment from file for a given Python version.")
55+
parser.add_argument("-n", "--name", type=str, help="The name of the created Python environment")
56+
parser.add_argument("-p", "--python", type=str, help="The version of the created Python environment")
57+
parser.add_argument("conda_file", help="The file for the created Python environment")
5658

5759
args = parser.parse_args()
5860

@@ -63,16 +65,16 @@ def temp_cd():
6365
python_replacement_string = "python {}*".format(args.python)
6466

6567
try:
66-
for dep_index, dep_value in enumerate(yaml_script['dependencies']):
67-
if re.match('python([ ><=*]+[0-9.*]*)?$', dep_value): # Match explicitly 'python' and its formats
68-
yaml_script['dependencies'].pop(dep_index)
68+
for dep_index, dep_value in enumerate(yaml_script["dependencies"]):
69+
if re.match("python([ ><=*]+[0-9.*]*)?$", dep_value): # Match explicitly 'python' and its formats
70+
yaml_script["dependencies"].pop(dep_index)
6971
break # Making the assumption there is only one Python entry, also avoids need to enumerate in reverse
7072
except (KeyError, TypeError):
7173
# Case of no dependencies key, or dependencies: None
72-
yaml_script['dependencies'] = []
74+
yaml_script["dependencies"] = []
7375
finally:
7476
# Ensure the python version is added in. Even if the code does not need it, we assume the env does
75-
yaml_script['dependencies'].insert(0, python_replacement_string)
77+
yaml_script["dependencies"].insert(0, python_replacement_string)
7678

7779
# Figure out conda path
7880
if "CONDA_EXE" in os.environ:
@@ -90,6 +92,6 @@ def temp_cd():
9092
# Write to a temp directory which will always be cleaned up
9193
with temp_cd():
9294
temp_file_name = "temp_script.yaml"
93-
with open(temp_file_name, 'w') as f:
95+
with open(temp_file_name, "w") as f:
9496
f.write(yaml.dump(yaml_script))
9597
sp.call("{} env create -n {} -f {}".format(conda_path, args.name, temp_file_name), shell=True)

docs/conf.py

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,23 @@
1515
# Incase the project was not installed
1616
import os
1717
import sys
18-
sys.path.insert(0, os.path.abspath('..'))
1918

19+
sys.path.insert(0, os.path.abspath(".."))
2020

2121

2222
# -- Project information -----------------------------------------------------
2323

24-
project = 'openmmdl'
25-
copyright = ("2022, Valerij Talagayev, Yu Chen, Niklas Piet Doering & Leon Obendorf. Project structure based on the "
26-
"Computational Molecular Science Python Cookiecutter version 1.1")
27-
author = 'Valerij Talagayev & Yu Chen'
24+
project = "openmmdl"
25+
copyright = (
26+
"2022, Valerij Talagayev, Yu Chen, Niklas Piet Doering & Leon Obendorf. Project structure based on the "
27+
"Computational Molecular Science Python Cookiecutter version 1.1"
28+
)
29+
author = "Valerij Talagayev & Yu Chen"
2830

2931
# The short X.Y version
30-
version = ''
32+
version = ""
3133
# The full version, including alpha/beta/rc tags
32-
release = ''
34+
release = ""
3335

3436

3537
# -- General configuration ---------------------------------------------------
@@ -58,16 +60,16 @@
5860
napoleon_use_ivar = True
5961

6062
# Add any paths that contain templates here, relative to this directory.
61-
templates_path = ['_templates']
63+
templates_path = ["_templates"]
6264

6365
# The suffix(es) of source filenames.
6466
# You can specify multiple suffix as a list of string:
6567
#
6668
# source_suffix = ['.rst', '.md']
67-
source_suffix = '.rst'
69+
source_suffix = ".rst"
6870

6971
# The master toctree document.
70-
master_doc = 'index'
72+
master_doc = "index"
7173

7274
# The language for content autogenerated by Sphinx. Refer to documentation
7375
# for a list of supported languages.
@@ -79,18 +81,18 @@
7981
# List of patterns, relative to source directory, that match files and
8082
# directories to ignore when looking for source files.
8183
# This pattern also affects html_static_path and html_extra_path .
82-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
84+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
8385

8486
# The name of the Pygments (syntax highlighting) style to use.
85-
pygments_style = 'default'
87+
pygments_style = "default"
8688

8789

8890
# -- Options for HTML output -------------------------------------------------
8991

9092
# The theme to use for HTML and HTML Help pages. See the documentation for
9193
# a list of builtin themes.
9294
#
93-
html_theme = 'renku'
95+
html_theme = "renku"
9496

9597
# Theme options are theme-specific and customize the look and feel of a theme
9698
# further. For a list of options available for each theme, see the
@@ -101,7 +103,7 @@
101103
# Add any paths that contain custom static files (such as style sheets) here,
102104
# relative to this directory. They are copied after the builtin static files,
103105
# so a file named "default.css" will overwrite the builtin "default.css".
104-
html_static_path = ['_static']
106+
html_static_path = ["_static"]
105107

106108
# Custom sidebar templates, must be a dictionary that maps document names
107109
# to template names.
@@ -117,7 +119,7 @@
117119
# -- Options for HTMLHelp output ---------------------------------------------
118120

119121
# Output file base name for HTML help builder.
120-
htmlhelp_basename = 'openmmdldoc'
122+
htmlhelp_basename = "openmmdldoc"
121123

122124

123125
# -- Options for LaTeX output ------------------------------------------------
@@ -126,15 +128,12 @@
126128
# The paper size ('letterpaper' or 'a4paper').
127129
#
128130
# 'papersize': 'letterpaper',
129-
130131
# The font size ('10pt', '11pt' or '12pt').
131132
#
132133
# 'pointsize': '10pt',
133-
134134
# Additional stuff for the LaTeX preamble.
135135
#
136136
# 'preamble': '',
137-
138137
# Latex figure (float) alignment
139138
#
140139
# 'figure_align': 'htbp',
@@ -144,19 +143,15 @@
144143
# (source start file, target name, title,
145144
# author, documentclass [howto, manual, or own class]).
146145
latex_documents = [
147-
(master_doc, 'openmmdl.tex', 'openmmdl Documentation',
148-
'openmmdl', 'manual'),
146+
(master_doc, "openmmdl.tex", "openmmdl Documentation", "openmmdl", "manual"),
149147
]
150148

151149

152150
# -- Options for manual page output ------------------------------------------
153151

154152
# One entry per manual page. List of tuples
155153
# (source start file, name, description, authors, manual section).
156-
man_pages = [
157-
(master_doc, 'openmmdl', 'openmmdl Documentation',
158-
[author], 1)
159-
]
154+
man_pages = [(master_doc, "openmmdl", "openmmdl Documentation", [author], 1)]
160155

161156

162157
# -- Options for Texinfo output ----------------------------------------------
@@ -165,9 +160,15 @@
165160
# (source start file, target name, title, author,
166161
# dir menu entry, description, category)
167162
texinfo_documents = [
168-
(master_doc, 'openmmdl', 'openmmdl Documentation',
169-
author, 'openmmdl', 'Preparation and Simulation of protein-ligand complexes',
170-
'Miscellaneous'),
163+
(
164+
master_doc,
165+
"openmmdl",
166+
"openmmdl Documentation",
167+
author,
168+
"openmmdl",
169+
"Preparation and Simulation of protein-ligand complexes",
170+
"Miscellaneous",
171+
),
171172
]
172173

173174

0 commit comments

Comments
 (0)