Skip to main content

mypy plugin for PynamoDB

Project description

pynamodb-mypy

A plugin for mypy which gives it deeper understanding of PynamoDB (beyond what's possible through type stubs).

Usage

Add it to the plugins option of the [mypy] section in your mypy.ini:

[mypy]
plugins = pynamodb_mypy

Nullable attributes

When declaring attributes with null=True, the value types would become optional. For example:

from pynamodb.attributes import UnicodeAttribute
from pynamodb.models import Model

class MyModel(Model):
  my_key = UnicodeAttribute()
  my_value = UnicodeAttribute(null=True)

...
my_model = MyModel.get('key')
if my_model.my_value.lower() == 'foo':  # error: Item "None" of "Optional[str]" has no attribute "lower"
   print("Value is foo")

would have to be changed to, e.g.:

if my_model.my_value and my_model.my_value.lower() == 'foo':
   print("Value is foo")

Project details


Download files

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

Source Distribution

pynamodb-mypy-0.0.3.tar.gz (4.7 kB view details)

Uploaded Source

File details

Details for the file pynamodb-mypy-0.0.3.tar.gz.

File metadata

  • Download URL: pynamodb-mypy-0.0.3.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for pynamodb-mypy-0.0.3.tar.gz
Algorithm Hash digest
SHA256 3726202b528608eb34c1a055dc8cd7fdd1b980fb6c4492be01bb4a5fcff23fe2
MD5 42c7d6b534032f200995ba1997e04693
BLAKE2b-256 5f84f4ec7c1668379c99b0679f1780ae4a85153e4d03749dc69050b54d6ddfce

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page