Repository navigation
Conversation
40881a1 to
8ffafa1
Compare
8ffafa1 to
8dbd922
Compare
| reportUnknownVariableType = false | ||
| reportUnknownMemberType = false | ||
| reportUnknownArgumentType = false | ||
| reportUnknownLambdaType = false |
There was a problem hiding this comment.
Why are these needed and can we have more isolated suppressions (e.g. per-file)? Or does the entire package need them?
There was a problem hiding this comment.
I'll look into fixing, since I'd rather not add suppressions
…wide Replace the four reportUnknown* settings in the generated pyproject with inline # pyright: ignore comments emitted only on the recursive/forward-ref schema lines that pyright cannot type (the lambda member targets and the assignment lines holding them). Keeps strict type checking everywhere else in the generated client.
| # recursive member target that resolves back to this tuple sees the in-progress | ||
| # object instead of recursing forever. | ||
| schema = Schema(id=id_, shape_type=shape_type, traits=_expand_traits(traits)) | ||
| _cache[key] = (data, schema) |
There was a problem hiding this comment.
another thread can get this schema before it's populated and cache an empty members_by_index
| members = schema.members | ||
| for index, mname in enumerate(member_names): | ||
| target_ref, member_traits = member_targets[index] | ||
| target = _resolve(target_ref) |
There was a problem hiding this comment.
If this raises an error, a partial schema could stay cached
| traits[tid] = Trait.new(tid) | ||
| bit >>= 1 | ||
| i += 1 | ||
| _traits_cache[indicator] = traits |
There was a problem hiding this comment.
This is shared across schemas- would it be possible to return a copy or cache something immutable?
| # Mutate the published members dict in place so a recursive target that | ||
| # captured it by reference during the cycle break observes the full map. | ||
| members = schema.members | ||
| for index, mname in enumerate(member_names): |
There was a problem hiding this comment.
Can we add tests for recursion, failed hydration, shared traits, and concurrent access?
|
|
||
| schema: Schema = field(repr=False) | ||
| """The schema of the operation.""" | ||
| static_schema: "StaticOperationSchema" = field(repr=False) |
There was a problem hiding this comment.
This makes callers use a private tuple format to construct APIOperation. Could we keep the existing constructor and add an internal lazy path?
In the schemas.py file, generate schema declarations as a compact tuples instead of a constructor or factory invocation. This expands lazily to the
Schemaclass object, but only on-use, rather than on import of the client.The result is a reduction in the memory footprint of schemas (delayed init, compact standby mode), and faster startup.
Both the faster startup and the size-on-disk reduction help any caller, and usage on Lambda in particular.
Code example:
effect on clients
picture of schemas.py only