aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Touhey <thomas@touhey.fr>2022-09-10 13:51:14 +0200
committerThomas Touhey <thomas@touhey.fr>2022-09-10 13:51:14 +0200
commit305a21b3bad893b0640afdc5cc8cafdd54216713 (patch)
tree1ff0dbf9dfb1bc65e2baa53a54dea1692b837fa0
parent9bdac9caff1e74d2c396ea68fbff89f99402aa90 (diff)
Fixed some static analyzer issues
-rw-r--r--docs/conf.py6
-rwxr-xr-xpyfingerd/fiction.py12
-rwxr-xr-xpyfingerd/posix.py2
-rwxr-xr-xsetup.py7
4 files changed, 17 insertions, 10 deletions
diff --git a/docs/conf.py b/docs/conf.py
index cea6783..332e75d 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -9,6 +9,7 @@
import os
import sys
+import typing as t
# -- Path setup --------------------------------------------------------------
@@ -28,8 +29,7 @@ author = 'Thomas Touhey'
def _get_release():
- from pyfingerd.version import version
-
+ from pyfingerd import __version__ as version
return version
@@ -122,7 +122,7 @@ htmlhelp_basename = 'pyfingerddoc'
# -- Options for LaTeX output ------------------------------------------------
-latex_elements = {
+latex_elements: t.Dict[str, str] = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',
diff --git a/pyfingerd/fiction.py b/pyfingerd/fiction.py
index 9632bb0..bebd6a1 100755
--- a/pyfingerd/fiction.py
+++ b/pyfingerd/fiction.py
@@ -151,11 +151,17 @@ class FictionalFingerSession(_FingerSession):
# Unchanged global.
# ---
-# TODO: Make that ``UnchangedType()`` (or ``type(Unchanged)()``) always
-# return Unchanged, like for None and NoneType.
-
class UnchangedType:
+ def __new__(mcls, *args, **kwargs):
+ # We want the same instance to be returned always when required.
+ try:
+ return mcls.__unchanged_value__
+ except AttributeError:
+ value = super().__new__(mcls, *args, **kwargs)
+ mcls.__unchanged_value__ = value
+ return value
+
def __repr__(self):
return 'Unchanged'
diff --git a/pyfingerd/posix.py b/pyfingerd/posix.py
index 88629b5..469a49f 100755
--- a/pyfingerd/posix.py
+++ b/pyfingerd/posix.py
@@ -45,7 +45,7 @@ class FingerPOSIXInterface(_FingerInterface):
self,
query: _t.Optional[str],
active: _t.Optional[bool],
- ) -> _Sequence[_FingerUser]:
+ ) -> _t.Sequence[_FingerUser]:
"""Look for users on POSIX-compliant systems.
The method for gathering users and sessions on such systems
diff --git a/setup.py b/setup.py
index 1a7dc05..8c4f705 100755
--- a/setup.py
+++ b/setup.py
@@ -6,10 +6,11 @@
"""Setup script for the pyfingerd Python package."""
import os.path as _path
+import typing as _t
-from setuptools import setup as _setup
+from setuptools import setup as _setup # type: ignore
-kwargs = {}
+kwargs: _t.Dict[str, _t.Any] = {}
# Add requirements using the requirements.txt file.
requirements = set()
@@ -20,7 +21,7 @@ kwargs['install_requires'] = sorted(filter(lambda x: x, requirements))
# Use Sphinx for building docs.
try:
- from sphinx.setup_command import BuildDoc as _BuildDoc
+ from sphinx.setup_command import BuildDoc as _BuildDoc # type: ignore
kwargs['cmdclass'] = {'build_sphinx': _BuildDoc}
except ImportError:
pass