File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -81,32 +81,11 @@ Common cookiecutter variables:
8181
8282## Error Patterns to Avoid
8383
84- ``` python
85- # BAD: Using os.path
86- import os
87- file_path = os.path.join(os.getcwd(), " file.txt" )
88-
89- # GOOD: Using pathlib
90- from pathlib import Path
91- file_path = Path.cwd() / " file.txt"
92-
93- # BAD: Print for logging
94- print (f " Error: { error} " )
95-
96- # GOOD: Proper logging
97- import logging
98- logger = logging.getLogger(__name__ )
99- logger.error(f " Operation failed: { error} " )
100-
101- # BAD: Generic exceptions
102- except Exception :
103- pass
104-
105- # GOOD: Specific handling
106- except FileNotFoundError as e:
107- logger.error(f " Configuration file not found: { e} " )
108- raise
109- ```
84+ | BAD | GOOD |
85+ | -----| ------|
86+ | ` os.path.join(os.getcwd(), "file.txt") ` | ` Path.cwd() / "file.txt" ` (use ` pathlib ` ) |
87+ | ` print(f"Error: {error}") ` | ` logger.error(f"Operation failed: {error}") ` (use ` logging ` ) |
88+ | ` except Exception: pass ` | ` except FileNotFoundError as e: logger.error(...); raise ` |
11089
11190## Testing Guidelines
11291
You can’t perform that action at this time.
0 commit comments