github / github/codeql

LGTM.com - false positive - Use of the return value of a procedure

Đang mở
#6,827 2 bình luận 0 reaction 0 người được giao Xem trên GitHub
acknowledged false-positive not security Python
Ngôn ngữ chính
CodeQL
Star
10.1k
Fork
2.1k
Merge trung bình
2 ngày 15 giờ
Pull request đã merge (30 ngày)
141

Mô tả

**Description of the false positive**

This is idiomatic Python and shouldn't raise a warning, even when the result of `main` is always `None`.
```python
if __name__ == "__main__":
sys.exit(main())
```
See:
https://docs.python.org/fr//3/library/__main__.html#packaging-considerations

> Since the call to `main` is wrapped in [`sys.exit()`](https://docs.python.org/fr//3/library/sys.html#sys.exit), the expectation is that your function will return some value acceptable as an input to [`sys.exit()`](https://docs.python.org/fr//3/library/sys.html#sys.exit); typically, an integer or `None` (which is implicitly returned if your function does not have a return statement).
>
> By proactively following this convention ourselves, our module will have the same behavior when run directly (i.e. `python3 echo.py`) as it will have if we later package it as a console script entry-point in a pip-installable package.

**URL to the alert on the project page on LGTM.com**

https://lgtm.com/projects/g/lamyj/odil/snapshot/00e9ad1ac34f7c310a264e3953e32d24b765cd2f/files/examples/python/convert.py?sort=name&dir=ASC&mode=heatmap#xf881ca92aa273c47:1

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.