You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**Rationale:** Module-level imports are executed once at module load time rather than every function call, improving performance. It also makes dependencies more visible and follows PEP 8 conventions.
102
102
103
-
---
103
+
---
104
+
105
+
106
+
### Fix #3: Nested If Statements (SIM102)
107
+
**Assigned to:** Mallikarjuna
108
+
**Location:** Lines 471-472 in `pandas/util/_validators.py`
109
+
**Issue:** Unnecessary nested if statements can be combined with `and`
110
+
111
+
**Before:**
112
+
```python
113
+
defcheck_dtype_backend(dtype_backend) -> None:
114
+
if dtype_backend isnot lib.no_default:
115
+
if dtype_backend notin ["numpy_nullable", "pyarrow"]:
116
+
raiseValueError(
117
+
f"dtype_backend {dtype_backend} is invalid, only 'numpy_nullable' and "
118
+
f"'pyarrow' are allowed.",
119
+
)
120
+
```
121
+
122
+
**After:**
123
+
```python
124
+
defcheck_dtype_backend(dtype_backend) -> None:
125
+
if dtype_backend isnot lib.no_default and dtype_backend notin ["numpy_nullable", "pyarrow"]:
126
+
raiseValueError(
127
+
f"dtype_backend {dtype_backend} is invalid, only 'numpy_nullable' and "
128
+
f"'pyarrow' are allowed.",
129
+
)
130
+
```
131
+
132
+
**Rationale:** Combining related conditions into a single if statement reduces nesting depth, improves readability, and makes the code more concise without losing clarity.
133
+
134
+
---
135
+
136
+
## Group Contributions
137
+
138
+
**Sandeep Ramavath:**
139
+
- Identified and fixed EM102 code smell (f-string in exception)
140
+
- Refactored exception handling to use variable assignment
141
+
- Impact: Improved exception handling best practices
142
+
143
+
**Nithikesh Bobbili:**
144
+
- Identified and fixed PLC0415 code smell (import location)
145
+
- Moved import statement to module level
146
+
- Impact: Better performance and code organization
147
+
148
+
**Mallikarjuna:**
149
+
- Identified and fixed SIM102 code smell (nested if statements)
150
+
- Simplified conditional logic by combining conditions
151
+
- Impact: Reduced code complexity and improved readability
0 commit comments