lablup / lablup/backend.ai

Enable RET502: Forbid empty return when function returns Optional

Open
#8,361 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
670
Forks
183
Avg merge
17h 7m
Merged PRs (30d)
358

Description

## Rule

**RET502**: `implicit-return-value`

## Purpose

Forbid implicit `return` (empty return) in functions that return Optional values. Forces explicit `return None` for clarity.

## Example

```python
# Bad
def get_user(id: int) -> Optional[User]:
if not valid:
return # RET502 - implicit None
return find_user(id)

# Good
def get_user(id: int) -> Optional[User]:
if not valid:
return None # explicit
return find_user(id)
```

## Auto-fix

✅ Available

## Notes

- Improves code readability by making None returns explicit
- Helps distinguish between "forgot to return" and "intentionally returning None"

JIRA Issue: BA-4022

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.