summary refs log tree commit diff
path: root/synapse/secrets.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2020-08-11 18:00:17 +0100
committerErik Johnston <erik@matrix.org>2020-08-11 18:00:17 +0100
commit0f1afbe8dc853c8726de797ede10cad2fe336b16 (patch)
treeb80df118d1c2a0a35fb745b47153284a9f97a9aa /synapse/secrets.py
parentMerge remote-tracking branch 'origin/master' into develop (diff)
downloadsynapse-0f1afbe8dc853c8726de797ede10cad2fe336b16.tar.xz
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.
Diffstat (limited to 'synapse/secrets.py')
-rw-r--r--synapse/secrets.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/synapse/secrets.py b/synapse/secrets.py
index 5f43f81eb0..ff86950a54 100644
--- a/synapse/secrets.py
+++ b/synapse/secrets.py
@@ -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: