fastspec 0.2.5__tar.gz → 0.2.7__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastspec
3
- Version: 0.2.5
3
+ Version: 0.2.7
4
4
  Summary: Dynamic OpenAPI, Discovery, and GraphQL spec client for Python — turn any API spec into a fully-typed async client with attribute chaining, streaming, and file uploads
5
5
  Author-email: Kerem Turgutlu <keremturgutlu@gmail.com>
6
6
  License-Expression: Apache-2.0
@@ -4,4 +4,4 @@ Modules:
4
4
 
5
5
  - `fastspec.gql`: Build GraphQL queries by field-checked attribute chaining, reuse distilled schemas, and combine queries into batched requests"""
6
6
 
7
- __version__ = "0.2.5"
7
+ __version__ = "0.2.7"
@@ -42,6 +42,7 @@ class OpFunc:
42
42
  self.__doc__ += ('\n\n`stream=True` returns an async iterator after awaiting the call. It cannot be combined with `raw_=True`.'
43
43
  if is_async_callable(self) else '\n\nStreaming requires an async client.')
44
44
  self.__doc__ += '\n\nHTTP errors raise `fasttransport.errors.APIError`; inspect its `status_code` and message.'
45
+ self.__doc__ += "\n\nA keyword argument that isn't a schema parameter, a call option or `stream` raises `TypeError`."
45
46
 
46
47
  def _repr_markdown_(self):
47
48
  mode = 'await ' if is_async_callable(self) else ''
@@ -77,6 +78,8 @@ def _bind(self:OpFunc, args, kwargs):
77
78
  def _split(self:OpFunc, kwargs):
78
79
  "Split kwargs into route/query/body/files + control kwargs."
79
80
  rsparams = {v:k for k,v in self.sparams.items()}
81
+ bad = [k for k in kwargs if k not in ('headers_', 'query_', 'body_', 'raw_', 'stream') and rsparams.get(k, k) not in self.op_spec.params]
82
+ if bad: raise TypeError(f"{self.name}() got unexpected keyword arguments: {', '.join(bad)}")
80
83
  params = {k:v for k,v in self.defaults.items() if v is not UNSET}
81
84
  params.update((rsparams.get(k, k), v) for k,v in kwargs.items() if v is not UNSET)
82
85
  stream = params.get("stream", False)
@@ -90,6 +93,7 @@ def _split(self:OpFunc, kwargs):
90
93
  elif orig in self.body_params: body[orig] = v
91
94
 
92
95
  query.update(kwargs.pop("query_", {}))
96
+ query = {k:v for k,v in query.items() if v is not None}
93
97
  body.update(kwargs.pop("body_", {}))
94
98
  if self.verb in ("GET", "DELETE", "HEAD", "OPTIONS") and not body: body = None
95
99
  return stream, headers, route, query, body, files
@@ -89,7 +89,8 @@ def _resolve_ref(ref, spec):
89
89
 
90
90
  # %% ../nbs/03_spec.ipynb #25ba8bb1
91
91
  def _resolve_obj(obj, spec):
92
- "Resolve a `$ref` object and merge local overrides when present."
92
+ "Normalize boolean schemas and resolve `$ref` with local overrides."
93
+ if isinstance(obj, bool): return {} if obj else {'not': {}}
93
94
  if "$ref" not in obj: return obj
94
95
  base = _resolve_ref(obj["$ref"], spec)
95
96
  if len(obj) == 1: return base
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastspec
3
- Version: 0.2.5
3
+ Version: 0.2.7
4
4
  Summary: Dynamic OpenAPI, Discovery, and GraphQL spec client for Python — turn any API spec into a fully-typed async client with attribute chaining, streaming, and file uploads
5
5
  Author-email: Kerem Turgutlu <keremturgutlu@gmail.com>
6
6
  License-Expression: Apache-2.0
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes