madpah / madpah/serializable

refactor: use native types over `typing` and remove `eval`s

Open
#24 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

idea
Dominant language
Python
Stars
7
Forks
6
PR merge metrics
No merged PRs in 30d

Description

that the f...

`eval` of `List[FooBar]( ... )` instead of native `list(...)` ...
the typing has no value here, this is pure runtime! and it is not only unnecessary overhead.

is this really needed?

and the `FooBar` is not even imported in this context, the typing just makes no sense !!!1elf

```py
_ARRAY_TYPES = {'List': List, 'Set': Set, 'SortedSet': Set}
_DEFAULT_XML_SEQUENCE = 100
_SORTED_CONTAINERS_TYPES = {'SortedList': List, 'SortedSet': Set}

# ...

# Will load any class already loaded assuming fully qualified name
self._type_ = eval(f'{mapped_array_type}[{results.get("array_of")}]')
self._concrete_type = eval(str(results.get("array_of")))

```

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue points to runtime type resolution using mapped_array_type and array_of; start by tracing how these values are handled during deserialization. Replace the typing and eval-based path with native runtime types, then verify JSON and XML serialization and deserialization still behave correctly without eval.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, security
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.