Skip to content

Commit

Permalink
chore: pyupgrade --py38-plus
Browse files Browse the repository at this point in the history
  • Loading branch information
deronnax committed Aug 6, 2024
1 parent 45f0b88 commit 941f7d5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 22 deletions.
2 changes: 1 addition & 1 deletion radicale/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def load(paths: Optional[Iterable[Tuple[str, bool]]] = None
config_source = "config file %r" % path
config: types.CONFIG
try:
with open(path, "r") as f:
with open(path) as f:
parser.read_file(f)
config = {s: {o: parser[s][o] for o in parser.options(s)}
for s in parser.sections()}
Expand Down
2 changes: 1 addition & 1 deletion radicale/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def server_bind(self) -> None:
if name == "certificate_authority" and not filename:
continue
try:
open(filename, "r").close()
open(filename).close()
except OSError as e:
raise RuntimeError(
"Invalid %s value for option %r in section %r in %s: %r "
Expand Down
25 changes: 11 additions & 14 deletions radicale/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,17 @@ def contextmanager(func: Callable[..., Iterator[_T]]
return result


if sys.version_info >= (3, 8):
from typing import Protocol, runtime_checkable

@runtime_checkable
class InputStream(Protocol):
def read(self, size: int = ...) -> bytes: ...

@runtime_checkable
class ErrorStream(Protocol):
def flush(self) -> object: ...
def write(self, s: str) -> object: ...
else:
ErrorStream = Any
InputStream = Any
from typing import Protocol, runtime_checkable


@runtime_checkable
class InputStream(Protocol):
def read(self, size: int = ...) -> bytes: ...

@runtime_checkable
class ErrorStream(Protocol):
def flush(self) -> object: ...
def write(self, s: str) -> object: ...

from radicale import item, storage # noqa:E402 isort:skip

Expand Down
7 changes: 1 addition & 6 deletions radicale/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,12 @@
# along with Radicale. If not, see <http://www.gnu.org/licenses/>.

import sys
from importlib import import_module
from importlib import import_module, metadata
from typing import Callable, Sequence, Type, TypeVar, Union

from radicale import config
from radicale.log import logger

if sys.version_info < (3, 8):
import pkg_resources
else:
from importlib import metadata

_T_co = TypeVar("_T_co", covariant=True)


Expand Down

0 comments on commit 941f7d5

Please sign in to comment.