From 2e48ffb76aa6b73aa567f31c47baf2392c4087bc Mon Sep 17 00:00:00 2001 From: Vasily Shamporov Date: Mon, 20 Nov 2023 12:42:48 +0100 Subject: [PATCH] Add a paragraph on bad file names to the style guide (#1439) --- docs/styleguide/PyGuide.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/docs/styleguide/PyGuide.md b/docs/styleguide/PyGuide.md index 070e35cad43..811c8633616 100644 --- a/docs/styleguide/PyGuide.md +++ b/docs/styleguide/PyGuide.md @@ -775,6 +775,39 @@ Always use a `.py` filename extension. Never use dashes. Python filenames must have a `.py` extension and must not contain dashes (`-`). This allows them to be imported and unit tested. +Avoid having `.py` files with names such as `utils`, `helpers` that are a "swiss army knife" containing many unrelated pieces of code used across the code base. +Instead group your new code in dedicated files/modules that are named explicitly according to the purpose of code. + +Bad: + +*utils.py* + +```python3 +def log_current_time(log_stream: LogStream): + ... + +def convert_checkpoint(ckpt: CheckpointType) -> AnotherCheckpointType: + ... +``` + +Good: + +*logger.py* + +```python3 +def log_current_time(log_stream: LogStream): + ... +``` + +*checkpointing/converter.py* + +```python3 +class CheckpointConverter: + # ... + def convert(self, ckpt: CheckpointType) -> AnotherCheckpointType: + pass +``` +