Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/expobrain/flake8-datetime-utcnow-plugin
https://github.com/expobrain/flake8-datetime-utcnow-plugin
Last synced: 28 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/expobrain/flake8-datetime-utcnow-plugin
- Owner: expobrain
- License: mit
- Created: 2020-09-08T19:31:44.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2024-06-27T20:57:33.000Z (4 months ago)
- Last Synced: 2024-09-28T22:23:44.584Z (about 1 month ago)
- Language: Python
- Homepage:
- Size: 190 KB
- Stars: 2
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-flake8-extensions - flake8-datetime-utcnow-plugin - Plugin to warn the developer of the usage of `datetime.utcnow()`. (Clean code)
README
# flake8_datetime_utcnow_plugin
## Rationale
Plugin for `flake8` to warn the developer of the usage of [datetime.utcnow()](https://docs.python.org/3/library/datetime.html#datetime.datetime.utcnow).
The problem with `datetime.utcnow()` is that indeed returns the current timestamp in the UTC timzone but the object is a naive `datetime`, that is doesn't have the `tzinfo` argument set.
Instead [datetime.now()](https://docs.python.org/3/library/datetime.html#datetime.datetime.utcnow) should be used passing the UTC timezone:
```python
from datetime import datetime, timezonedatetime.now(timezone.utc)
```## Installation
To install the plugin and `flake8`:
```
pip install flake8_datetime_utcnow_plugin
```