google / google/python-fire

Improve error message when required argument is missing

Đang mở
#633 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Python
Star
28.2k
Fork
1.5k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

## Description
When a required function argument is not provided via the command line, Python Fire raises a generic TypeError that doesn't clearly indicate which argument is missing or how to provide it.

## Current Behavior
```bash
$ python my_script.py greet
TypeError: greet() missing 1 required positional argument: 'name'
```

## Expected Behavior
A more user-friendly error message that would guide the user:
```
$ python my_script.py greet
Error: Missing required argument 'name'
Usage: my_script.py greet
```

## Motivation
This would significantly improve the user experience, especially for new users who are unfamiliar with Python tracebacks. Clear error messages are crucial for CLI tools.

## Environment
- Python Fire version: 0.7.1
- Python version: 3.11
- OS: macOS

## Possible Solution
Catch TypeError exceptions in the argument parsing logic and check if they're related to missing arguments, then provide a more descriptive message with usage hints.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.