mirror of
https://github.com/kennethreitz/pydantic.git
synced 2026-06-05 23:00:18 +00:00
bd0a28d8d7
* Avoid __dict__ and __weakref__ attributes in AnyUrl and _BaseAddress subclasses When inheriting from a class with `__slots__`, [child subclasses will get a `__dict__` and `__weakref__` unless they also define `__slots__`](https://docs.python.org/3/reference/datamodel.html#notes-on-using-slots). ```python from pydantic import AnyUrl, AnyHttpUrl class AnyOtherHttpUrl(AnyUrl): allowed_schemes = {'http', 'https'} __slots__ = () print(set(dir(AnyHttpUrl)) - set(dir(AnyUrl))) #> {'__weakref__', '__dict__'} print(set(dir(AnyOtherHttpUrl)) - set(dir(AnyUrl))) #> set() ``` * Update changes/2890-nuno-andre.md Co-authored-by: Samuel Colvin <samcolvin@gmail.com> Co-authored-by: Samuel Colvin <s@muelcolvin.com>
Pending Changes
This directory contains files describing changes to pydantic since the last release.
If you're creating a pull request, please add a new file to this directory called
<pull request or issue id>-<github username>.md. It should be formatted as a single paragraph of markdown
The contents of this file will be used to update HISTORY.md before the next release.