Skip to content

Commit

Permalink
Add a paragraph on bad file names to the style guide (#1439)
Browse files Browse the repository at this point in the history
  • Loading branch information
vshampor authored Nov 20, 2023
1 parent b6910ea commit 2e48ffb
Showing 1 changed file with 33 additions and 0 deletions.
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

0 comments on commit 2e48ffb

Please sign in to comment.