Skip to main content

Plugin to check that utcnow() is not used in favour of now(UTC)

Project description

flake8_datetime_utcnow_plugin

Rationale

Plugin for flake8 to warn the developer of the usage of datetime.utcnow().

The problem with datetme.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:

from datetime import datetime, timezone

datetime.now(timezone.utc)

Installation

To install the plugin and flake8:

pip install flake8_datetime_utcnow_plugin

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for flake8-datetime-utcnow-plugin, version 0.1.2
Filename, size File type Python version Upload date Hashes
Filename, size flake8_datetime_utcnow_plugin-0.1.2-py3-none-any.whl (4.2 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size flake8-datetime-utcnow-plugin-0.1.2.tar.gz (3.2 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page