Einspect

Latest version: v0.5.16

Safety actively analyzes 638430 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 2 of 7

0.5.9

Added
- `impl` now has an optional keyword argument `alloc`, with options of `"all", "sequence", "mapping"`. The default of `None` will automatically allocate `PyMethods` when a slot name being set is not allocated on the type.
- The setting `"all"` will unconditionally allocate all `PyMethods` (PyAsyncMethods, PyNumberMethods, PySequenceMethods, PyMappingMethods) before the impl.
- "sequence" and "mapping" options will allocate the respective PyMethods when the slot name is ambiguious (such as `__len__` and `__getitem__`, which are in both `PySequenceMethods` and `PyMappingMethods`.

- `orig` now works within `__new__` impls. `orig(cls)` will return a custom slot wrapper to `tp_new` that will resolve further subclasses without a custom `__new__` as `object.__new__` instead. This also handles the special case where `object.__new__` has a different signature than `CustomType.__new__`
python
from einspect import impl, orig


impl(object)
def __new__(cls, *args, **kwargs):
print("in new:", cls, args, kwargs)
return orig(cls).__new__(cls, *args, **kwargs)

class Foo:
...

print(object())
in new: <class 'object'> () {}
<object object at 0x000001EA9D2A4FE0>

print(Foo())
in new: <class '__main__.Foo'> () {}
<__main__.Foo object at 0x000001EA9D797DD0>


**Full Changelog**: https://github.com/ionite34/einspect/compare/v0.5.8...v0.5.9

0.5.8

Enhancements
* Move `_pyobject` type hint eval to define time in `__init_subclass__`
- Improves internal reliability and performance by moving `get_type_hints` call to define time, avoids issues in runtime after internal types are modified.


**Full Changelog**: https://github.com/ionite34/einspect/compare/v0.5.7...v0.5.8

0.5.7.post1

Docs
* Add orig and extending types documentation


> This update only affects sphinx docs and `README.md`

**Full Changelog**: https://github.com/ionite34/einspect/compare/v0.5.7...v0.5.7.post1

0.5.7

Added
- Supports supplying multiple string attributes in `TypeView.__setattr__` to set all given names to the same value
python
from einspect import view

view(str)["foo", "bar"] = lambda x: x * 2

print("abc".foo())
abcabc
print("abc".bar())
abcabc



**Full Changelog**: https://github.com/ionite34/einspect/compare/v0.5.6...v0.5.7

0.5.6

Adds
- `View.swap()`
> This is like `View.move_from()`, but swaps data from the target view from the supplied viewable object

python
from einspect import view

view("dog").swap("cat")

print("dog", "cat")
cat dog

view(max).swap(min)

print(min(1, 2, 3), max(1, 2, 3))
3 1


**Full Changelog**: https://github.com/ionite34/einspect/compare/v0.5.5...v0.5.6

0.5.5

Added
* Implement sort() for TupleView and StrView
> This sorts the tuple or string in-place, like `list.sort`, and accepts optional `key` and `reverse` arguments.
python
from einspect import view

s = "a1b2c3"
view(s).sort()

print(s)
>> 123abc

python
from einspect import view

t = (3, 1, 4, 2)
view(t).sort()

print(t)
>> (1, 2, 3, 4)



Fixes
* Add 2 missing `__all__` declarations in `api` and `types` by ionite34 in https://github.com/ionite34/einspect/pull/42
* Change README heading phrasing, update lock file by ionite34 in https://github.com/ionite34/einspect/pull/43
* Switch from yanked version of sphinx-autodoc-typehints by ionite34 in https://github.com/ionite34/einspect/pull/44


**Full Changelog**: https://github.com/ionite34/einspect/compare/v0.5.4...v0.5.5

Page 2 of 7

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.