Skip to content

Commit a912bdc

Browse files
Merge pull request #9653 from OpenMined/koen/readable-conditions
docs: name each check of a long condition
2 parents fb61754 + 0093480 commit a912bdc

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

‎dev-guidelines/guidelines.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,15 @@ Integration tests need OAuth tokens in the `credentials/` folder, and the env va
176176

177177
- Prefer simple code that is easy to read. Avoid deeply nested dict and list comprehensions with
178178
complicated control flow.
179+
- When a condition combines more than two checks, give each check a variable that says what it
180+
checks, then combine the variables:
181+
182+
```python
183+
has_file = path in self.file_hashes
184+
in_immutable_collection = any(path.is_relative_to(p) for p in immutable_subpaths)
185+
denied = self.freeze_private_datasets and has_file and in_immutable_collection
186+
```
187+
179188
- Put a repeated or magic value in a module-level constant.
180189
- Build strings with f-strings.
181190
- Keep imports at the top of the file where possible, in this order: standard library,

0 commit comments

Comments
 (0)