Skip to main content

Makes typed arguments Optional when the default argument is None

Project description

auto-optional

Makes typed arguments Optional when the default argument is None.

For example:

def foo(bar: str = None):
    ...

Would turn into

from typing import Optional
def foo(bar: Optional[str] = None):
    ...

Install

Install with pip install auto-optional.

run

You can run this with auto-optional [path] (path is an optional argument).

Properties

  • Existing imports are reused.
  • import as statements are properly handled.

Things of note

For all these points I welcome pull-requests.

  • There is no exclude (path patterns) option yet
  • There is no ignore (code line) option yet
  • Code is aways read and written as UTF-8 (which is accurate most of the time).

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

auto-optional-0.1.1.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

auto_optional-0.1.1-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file auto-optional-0.1.1.tar.gz.

File metadata

  • Download URL: auto-optional-0.1.1.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.8 CPython/3.8.11 Linux/5.8.0-1039-azure

File hashes

Hashes for auto-optional-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b37c84089c5b3c5b52a7d39382868850a8b1a0a6fabdffcf64400ab892ab264a
MD5 8f1e140c3acd99ffb1db8724e8e97355
BLAKE2b-256 62ccc1c3fd09c58a0f617570b7b4b1d7d2944e50772b0a4c760124db534ce7a7

See more details on using hashes here.

File details

Details for the file auto_optional-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: auto_optional-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.8 CPython/3.8.11 Linux/5.8.0-1039-azure

File hashes

Hashes for auto_optional-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c8034048956ec9818220678efc1a5ef4082652eb14e7884b0fc9d80b8d386fae
MD5 6f4af04d1a1ede0969dad2b2092b5b18
BLAKE2b-256 4ee077163c6c2535f705fc47f3d4db83b36f12c3cf33b94f1166bb5dcb771917

See more details on using hashes here.

Supported by

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