Improve the name and type annotation of the tempfile factory

This commit is contained in:
Jean-Paul Calderone 2023-07-11 16:15:56 -04:00
parent 3129898563
commit c838967a54
4 changed files with 6 additions and 6 deletions

View File

@ -1030,14 +1030,14 @@ class _Client(node.Node, pollmixin.PollMixin):
def init_web(self, webport):
self.log("init_web(webport=%s)", args=(webport,))
from allmydata.webish import WebishServer, anonymous_tempfile
from allmydata.webish import WebishServer, anonymous_tempfile_factory
nodeurl_path = self.config.get_config_path("node.url")
staticdir_config = self.config.get_config("node", "web.static", "public_html")
staticdir = self.config.get_config_path(staticdir_config)
ws = WebishServer(
self,
webport,
anonymous_tempfile(self._get_tempdir()),
anonymous_tempfile_factory(self._get_tempdir()),
nodeurl_path,
staticdir,
)

View File

@ -341,7 +341,7 @@ class WebMixin(TimezoneMixin):
self.ws = webish.WebishServer(
self.s,
"0",
webish.anonymous_tempfile(tempdir.path),
webish.anonymous_tempfile_factory(tempdir.path),
staticdir=self.staticdir,
clock=self.clock,
now_fn=lambda:self.fakeTime,

View File

@ -50,7 +50,7 @@ from ..common import (
from ...webish import (
TahoeLAFSRequest,
TahoeLAFSSite,
anonymous_tempfile,
anonymous_tempfile_factory,
)
@ -179,7 +179,7 @@ class TahoeLAFSSiteTests(SyncTestCase):
FilePath(tempdir).makedirs()
site = TahoeLAFSSite(
anonymous_tempfile(tempdir),
anonymous_tempfile_factory(tempdir),
Resource(),
logPath=logPath,
)

View File

@ -217,7 +217,7 @@ def censor(queryargs: bytes) -> bytes:
return urlencode(result, safe="[]").encode("ascii")
def anonymous_tempfile(tempdir: bytes) -> BinaryIO:
def anonymous_tempfile_factory(tempdir: bytes) -> Callable[[], BinaryIO]:
"""
Create a no-argument callable for creating a new temporary file in the
given directory.