Use attrs, to remove verbose __init__ and __repr__ methods

Backwards compatibility is strictly preserved in `__init__`, including parameter names, defaults and position. Whenever that's difficult using `attrs`, the custom `__init__` is kept instead (for the time being).

`__repr__` methods have changed to the format `attrs` use, but people don't rely on this for anything other than debug output, so it shouldn't be a problem.
This commit is contained in:
Mads Marquart
2019-02-24 05:17:16 +01:00
parent f916cb3b53
commit 8ae8435940
12 changed files with 198 additions and 325 deletions

View File

@@ -1,22 +1,24 @@
# -*- coding: UTF-8 -*-
from __future__ import unicode_literals
import attr
from ._thread import ThreadType, Thread
@attr.s(cmp=False, init=False)
class Page(Thread):
"""Represents a Facebook page. Inherits `Thread`"""
#: The page's custom url
url = None
url = attr.ib(None)
#: The name of the page's location city
city = None
city = attr.ib(None)
#: Amount of likes the page has
likes = None
likes = attr.ib(None)
#: Some extra information about the page
sub_title = None
sub_title = attr.ib(None)
#: The page's category
category = None
category = attr.ib(None)
def __init__(
self,