typedparser 0.7.2__tar.gz → 0.9.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -186,7 +186,7 @@
186
186
  same "printed page" as the copyright notice for easier
187
187
  identification within third-party archives.
188
188
 
189
- Copyright 2023 gingsi
189
+ Copyright 2023 simonging
190
190
 
191
191
  Licensed under the Apache License, Version 2.0 (the "License");
192
192
  you may not use this file except in compliance with the License.
@@ -1,10 +1,10 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: typedparser
3
- Version: 0.7.2
3
+ Version: 0.9.1
4
4
  Summary: Extension for python argparse with typehints and typechecks.
5
- Author: gingsi
5
+ Author: simonging
6
6
  License: Apache-2.0
7
- Project-URL: Project-URL, https://github.com/gingsi/typedparser
7
+ Project-URL: Project-URL, https://github.com/simonging/typedparser
8
8
  Keywords: attrs,typing,dict,attr
9
9
  Platform: any
10
10
  Classifier: Development Status :: 3 - Alpha
@@ -25,13 +25,13 @@ Requires-Dist: numpy
25
25
  # typedparser
26
26
 
27
27
  <p align="center">
28
- <a href="https://github.com/gingsi/typedparser/actions/workflows/build-py37.yml">
29
- <img alt="build 3.7 status" title="build 3.7 status" src="https://img.shields.io/github/actions/workflow/status/gingsi/typedparser/build-py37.yml?branch=main&label=build%203.7" />
28
+ <a href="https://github.com/simonging/typedparser/actions/workflows/build-py37.yml">
29
+ <img alt="build 3.7 status" title="build 3.7 status" src="https://img.shields.io/github/actions/workflow/status/simonging/typedparser/build-py37.yml?branch=main&label=build%203.7" />
30
30
  </a>
31
- <a href="https://github.com/gingsi/typedparser/actions/workflows/build-py310.yml">
32
- <img alt="build 3.10 status" title="build 3.10 status" src="https://img.shields.io/github/actions/workflow/status/gingsi/typedparser/build-py310.yml?branch=main&label=build%203.10" />
31
+ <a href="https://github.com/simonging/typedparser/actions/workflows/build-py310.yml">
32
+ <img alt="build 3.10 status" title="build 3.10 status" src="https://img.shields.io/github/actions/workflow/status/simonging/typedparser/build-py310.yml?branch=main&label=build%203.10" />
33
33
  </a>
34
- <img alt="coverage" title="coverage" src="https://raw.githubusercontent.com/gingsi/typedparser/main/docs/coverage.svg" />
34
+ <img alt="coverage" title="coverage" src="https://raw.githubusercontent.com/simonging/typedparser/main/docs/coverage.svg" />
35
35
  <a href="https://pypi.org/project/typedparser/">
36
36
  <img alt="version" title="version" src="https://img.shields.io/pypi/v/typedparser?color=success" />
37
37
  </a>
@@ -1,13 +1,13 @@
1
1
  # typedparser
2
2
 
3
3
  <p align="center">
4
- <a href="https://github.com/gingsi/typedparser/actions/workflows/build-py37.yml">
5
- <img alt="build 3.7 status" title="build 3.7 status" src="https://img.shields.io/github/actions/workflow/status/gingsi/typedparser/build-py37.yml?branch=main&label=build%203.7" />
4
+ <a href="https://github.com/simonging/typedparser/actions/workflows/build-py37.yml">
5
+ <img alt="build 3.7 status" title="build 3.7 status" src="https://img.shields.io/github/actions/workflow/status/simonging/typedparser/build-py37.yml?branch=main&label=build%203.7" />
6
6
  </a>
7
- <a href="https://github.com/gingsi/typedparser/actions/workflows/build-py310.yml">
8
- <img alt="build 3.10 status" title="build 3.10 status" src="https://img.shields.io/github/actions/workflow/status/gingsi/typedparser/build-py310.yml?branch=main&label=build%203.10" />
7
+ <a href="https://github.com/simonging/typedparser/actions/workflows/build-py310.yml">
8
+ <img alt="build 3.10 status" title="build 3.10 status" src="https://img.shields.io/github/actions/workflow/status/simonging/typedparser/build-py310.yml?branch=main&label=build%203.10" />
9
9
  </a>
10
- <img alt="coverage" title="coverage" src="https://raw.githubusercontent.com/gingsi/typedparser/main/docs/coverage.svg" />
10
+ <img alt="coverage" title="coverage" src="https://raw.githubusercontent.com/simonging/typedparser/main/docs/coverage.svg" />
11
11
  <a href="https://pypi.org/project/typedparser/">
12
12
  <img alt="version" title="version" src="https://img.shields.io/pypi/v/typedparser?color=success" />
13
13
  </a>
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
6
6
  name = "typedparser"
7
7
  description = "Extension for python argparse with typehints and typechecks."
8
8
  readme = "README.md"
9
- authors = [{ "name" = "gingsi" }]
9
+ authors = [{ "name" = "simonging" }]
10
10
  requires-python = ">=3.7"
11
11
  license = { text = "Apache-2.0" }
12
12
  keywords = ["attrs", "typing", "dict", "attr"]
@@ -24,7 +24,7 @@ classifiers = [
24
24
  dynamic = ["version", "dependencies"]
25
25
 
26
26
  [project.urls]
27
- Project-URL = "https://github.com/gingsi/typedparser"
27
+ Project-URL = "https://github.com/simonging/typedparser"
28
28
 
29
29
  [tool.setuptools]
30
30
  zip-safe = true
@@ -13,6 +13,6 @@ __all__ = [
13
13
  "VerboseQuietArgs",
14
14
  "CustomArgparseFmt",
15
15
  "get_attr_names",
16
- "define", # deprecated, use from attrs import define directly instead
16
+ "define", # deprecated, use `from attr import define` directly instead
17
17
  ]
18
- __version__ = "0.7.2"
18
+ __version__ = "0.9.1"
@@ -15,6 +15,7 @@ from typing import (
15
15
  List,
16
16
  Optional,
17
17
  get_type_hints,
18
+ Callable,
18
19
  )
19
20
 
20
21
  import attrs
@@ -32,10 +33,13 @@ except ImportError:
32
33
 
33
34
  # default conversions allow to convert instead of raising errors in case of matching types
34
35
  # e.g. create Path given str, or create float given int
35
- conversion_type = List[Tuple[Tuple[Type, ...], Type]]
36
+ # syntax: ((source_type1, source_type2, ...), target_type, conversion_function)
37
+ # if conversion_function is none, use target_type as conversion function
38
+ conversion_type = List[Tuple[Tuple[Type, ...], Type, Optional[Callable]]]
36
39
  default_conversions: conversion_type = [
37
- ((str,), Path),
38
- ((int,), float),
40
+ ((str,), Path, None),
41
+ ((int,), float, None),
42
+ ((Path,), str, Path.as_posix),
39
43
  ]
40
44
 
41
45
 
@@ -384,11 +388,13 @@ def _parse_nested(
384
388
  return maybe_raise_typeerorr(f"{err_msg}. Abstract collections are not supported.")
385
389
 
386
390
  # add explicit conversions
387
- for convert_source, convert_target in conversions:
391
+ for convert_source, convert_target, convert_callable in conversions:
388
392
  if not isclass(typ):
389
393
  continue
390
394
  if issubclass(typ, convert_target) and isinstance(value, convert_source):
391
- return convert_target(value)
395
+ if convert_callable is None:
396
+ convert_callable = convert_target
397
+ return convert_callable(value)
392
398
 
393
399
  if strict:
394
400
  add_info = ""
@@ -1,10 +1,10 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: typedparser
3
- Version: 0.7.2
3
+ Version: 0.9.1
4
4
  Summary: Extension for python argparse with typehints and typechecks.
5
- Author: gingsi
5
+ Author: simonging
6
6
  License: Apache-2.0
7
- Project-URL: Project-URL, https://github.com/gingsi/typedparser
7
+ Project-URL: Project-URL, https://github.com/simonging/typedparser
8
8
  Keywords: attrs,typing,dict,attr
9
9
  Platform: any
10
10
  Classifier: Development Status :: 3 - Alpha
@@ -25,13 +25,13 @@ Requires-Dist: numpy
25
25
  # typedparser
26
26
 
27
27
  <p align="center">
28
- <a href="https://github.com/gingsi/typedparser/actions/workflows/build-py37.yml">
29
- <img alt="build 3.7 status" title="build 3.7 status" src="https://img.shields.io/github/actions/workflow/status/gingsi/typedparser/build-py37.yml?branch=main&label=build%203.7" />
28
+ <a href="https://github.com/simonging/typedparser/actions/workflows/build-py37.yml">
29
+ <img alt="build 3.7 status" title="build 3.7 status" src="https://img.shields.io/github/actions/workflow/status/simonging/typedparser/build-py37.yml?branch=main&label=build%203.7" />
30
30
  </a>
31
- <a href="https://github.com/gingsi/typedparser/actions/workflows/build-py310.yml">
32
- <img alt="build 3.10 status" title="build 3.10 status" src="https://img.shields.io/github/actions/workflow/status/gingsi/typedparser/build-py310.yml?branch=main&label=build%203.10" />
31
+ <a href="https://github.com/simonging/typedparser/actions/workflows/build-py310.yml">
32
+ <img alt="build 3.10 status" title="build 3.10 status" src="https://img.shields.io/github/actions/workflow/status/simonging/typedparser/build-py310.yml?branch=main&label=build%203.10" />
33
33
  </a>
34
- <img alt="coverage" title="coverage" src="https://raw.githubusercontent.com/gingsi/typedparser/main/docs/coverage.svg" />
34
+ <img alt="coverage" title="coverage" src="https://raw.githubusercontent.com/simonging/typedparser/main/docs/coverage.svg" />
35
35
  <a href="https://pypi.org/project/typedparser/">
36
36
  <img alt="version" title="version" src="https://img.shields.io/pypi/v/typedparser?color=success" />
37
37
  </a>
File without changes