Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a paragraph on bad file names to the style guide #1439

Merged
merged 2 commits into from
Nov 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions docs/styleguide/PyGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

<a id="s4.8-main"></a>
<a id="4.8-main"></a>
<a id="main"></a>
Expand Down