Files
pydantic/changes
Nuno André bd0a28d8d7 Avoid __dict__ and __weakref__ attributes in AnyUrl and _BaseAddress subclasses (#2890)
* 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>
2022-08-04 11:56:37 +00:00
..
2019-10-07 17:19:01 +01:00

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.