Skip to content

Commit

Permalink
python: Add pylint check W0109 (duplicate-key)
Browse files Browse the repository at this point in the history
Duplicated dict keys will silently override one another.
  • Loading branch information
jngrad committed Feb 23, 2023
1 parent 881d214 commit a716f36
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
1 change: 1 addition & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ disable=all
# multiple time (only on the command line, not in the configuration file where
# it should appear only once). See also the "--disable" option for examples.
enable=dangerous-default-value, # W0102
duplicate-key, # W0109
wildcard-import, # W0401
assert-on-tuple, # W0199
unused-import, # W0611
Expand Down
14 changes: 4 additions & 10 deletions src/python/espressomd/reaction_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,16 +503,10 @@ def get_status(self):
"""

self.check_reaction_method()
reactions_list = []

for reaction in self.reactions:
reaction = {"reactant_coefficients": reaction.reactant_coefficients,
"reactant_types": reaction.reactant_types,
"product_types": reaction.product_types,
"product_coefficients": reaction.product_coefficients,
"reactant_types": reaction.reactant_types,
"gamma": reaction.gamma}
reactions_list.append(reaction)
property_keys = {"reactant_coefficients", "reactant_types",
"product_coefficients", "product_types", "gamma"}
reactions_list = [{key: getattr(reaction, key) for key in property_keys}
for reaction in self.reactions]

return {"reactions": reactions_list, "kT": self.kT,
"exclusion_range": self.exclusion_range,
Expand Down

0 comments on commit a716f36

Please sign in to comment.