Change HomeServer definition to work with typing.

Duplicating function signatures between server.py and server.pyi is
silly. This commit changes that by changing all `build_*` methods to
`get_*` methods and changing the `_make_dependency_method` to work work
as a descriptor that caches the produced value.

There are some changes in other files that were made to fix the typing
in server.py.
This commit is contained in:
Erik Johnston 2020-08-11 18:00:17 +01:00
parent aa827b6ad7
commit 0f1afbe8dc
7 changed files with 264 additions and 399 deletions

View file

@ -25,8 +25,12 @@ import sys
if sys.version_info[0:2] >= (3, 6):
import secrets
def Secrets():
return secrets
class Secrets:
def token_bytes(self, nbytes=32):
return secrets.token_bytes(nbytes)
def token_hex(self, nbytes=32):
return secrets.token_hex(nbytes)
else: