Skip to content

Checking the python code that is distribuited with PLUMED#1375

Merged
carlocamilloni merged 3 commits intoplumed:masterfrom
Iximiel:feature/python-codechek
Mar 27, 2026
Merged

Checking the python code that is distribuited with PLUMED#1375
carlocamilloni merged 3 commits intoplumed:masterfrom
Iximiel:feature/python-codechek

Conversation

@Iximiel
Copy link
Copy Markdown
Member

@Iximiel Iximiel commented Mar 5, 2026

Description

This is a follow up to the changes made with #1372, I just added some check to the code and to the formattation of (most of) the python files, mainly to the tests and to the manual builder, in a way that now it should be easier to follow the changes and can catch some unwanted bugs.

I also updated the changelog, as I should have done before...

Target release

I would like my code to appear in release v2.11

Type of contribution
  • changes to code or doc authored by PLUMED developers, or additions of code in the core or within the default modules
  • changes to a module not authored by you
  • new module contribution or edit of a module authored by you
Copyright
  • I agree to transfer the copyright of the code I have written to the PLUMED developers or to the author of the code I am modifying.
  • the module I added or modified contains a COPYRIGHT file with the correct license information. Code should be released under an open source license. I also used the command cd src && ./header.sh mymodulename in order to make sure the headers of the module are correct.
Tests
  • I added a new regtest or modified an existing regtest to validate my changes.
  • I verified that all regtests are passed successfully on GitHub Actions.

data = np.zeros((1))
p.cmd("setMemoryForData " + name, data )
return data
xyz = open(filename)

Check warning

Code scanning / CodeQL

File is not always closed Warning test

File may not be closed if
this operation
raises an exception.
File may not be closed if
this operation
raises an exception.
File may not be closed if
this operation
raises an exception.
File may not be closed if
this operation
raises an exception.
File may not be closed if
this operation
raises an exception.
# Read in the correct answers that were calculated directly using PLUMED
correct_torsions = np.loadtxt("colvar.ref")
# Open an output file
of = open("logfile", "w+")

Check warning

Code scanning / CodeQL

File is not always closed Warning test

File may not be closed if
this operation
raises an exception.
broken_inputs = []

# Create the general pages
actions = set()

Check notice

Code scanning / CodeQL

Unused global variable Note

The global variable 'actions' is not used.
try:
plumed.write_pandas(d, "COLVAR_write3")
self.assertTrue(False)
except TypeError:

Check notice

Code scanning / CodeQL

Empty except Note test

'except' clause does nothing but pass and there is no explanatory comment.
@Iximiel Iximiel force-pushed the feature/python-codechek branch from 0105f58 to 84e24c4 Compare March 9, 2026 11:20
@Iximiel
Copy link
Copy Markdown
Member Author

Iximiel commented Mar 9, 2026

@carlocamilloni carlocamilloni merged commit f100869 into plumed:master Mar 27, 2026
25 of 28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants