Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow frozenset in attributes parameter of clean function #29

Open
ashrub-holvi opened this issue Nov 28, 2023 · 4 comments
Open

Allow frozenset in attributes parameter of clean function #29

ashrub-holvi opened this issue Nov 28, 2023 · 4 comments

Comments

@ashrub-holvi
Copy link

Now it's dict[str, set[str]], and attempt to use frozenset will return

TypeError: argument 'attributes': 'frozenset' object cannot be converted to 'PySet'

but IMO using frozenset is a good practice, because if data is immutable good to use immutable type, for example allowed attributes can be defined in configuration and it's safer to use immutable type.

@ashrub-holvi
Copy link
Author

also MappingProxyType can be allowed instead of dictionary

@adamchainz
Copy link
Contributor

The TypeError comes from PyO3. It’s not clear to me from the PyO3 arg docs if there’s an easy way to allow all kinds of mappings or sets and have PyO3 convert them.

@messense
Copy link
Owner

messense commented Dec 7, 2023

Adding support for frozenset in PyO3/pyo3#3632

@ashrub-holvi
Copy link
Author

Thank you! Do you think it's possible to add support of MappingProxyType? As I understand it's only way to have read-only dictionaries without adding third-party libraries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants