* [gentoo-commits] proj/pkgcore/snakeoil:master commit in: src/snakeoil/
@ 2023-01-17 20:39 Arthur Zamarin
0 siblings, 0 replies; 9+ messages in thread
From: Arthur Zamarin @ 2023-01-17 20:39 UTC (permalink / raw
To: gentoo-commits
commit: 34f1962cde1d4ef5e5737048bee2a88abdba804a
Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Tue Jan 17 20:38:12 2023 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Tue Jan 17 20:38:12 2023 +0000
URL: https://gitweb.gentoo.org/proj/pkgcore/snakeoil.git/commit/?id=34f1962c
formatters: add typing annotations
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>
src/snakeoil/formatters.py | 48 +++++++++++++++++++++++++++++++---------------
1 file changed, 33 insertions(+), 15 deletions(-)
diff --git a/src/snakeoil/formatters.py b/src/snakeoil/formatters.py
index 3faf661a..151778c6 100644
--- a/src/snakeoil/formatters.py
+++ b/src/snakeoil/formatters.py
@@ -4,6 +4,7 @@ import errno
import io
import locale
import os
+import typing
from functools import partial
from .klass import GetAttrProxy, steal_docs
@@ -49,7 +50,11 @@ class Formatter:
self.autoline = True
self.wrap = False
- def write(self, *args, **kwargs):
+ def write(
+ self,
+ *args: typing.Union[None, str, typing.Callable[["Formatter"], None]],
+ **kwargs,
+ ):
"""Write something to the stream.
Acceptable arguments are:
@@ -80,7 +85,7 @@ class Formatter:
to write.
"""
- def fg(self, color=None):
+ def fg(self, color: typing.Optional[str] = None) -> str:
"""Change foreground color.
:param color: color to change to. A default is used if omitted.
@@ -89,7 +94,7 @@ class Formatter:
color, if possible for this formatter.
"""
- def bg(self, color=None):
+ def bg(self, color: typing.Optional[str] = None) -> str:
"""Change background color.
:param color: color to change to. A default is used if omitted.
@@ -98,15 +103,21 @@ class Formatter:
color, if possible for this formatter.
"""
- def error(self, message):
+ def error(
+ self, message: typing.Union[None, str, typing.Callable[["Formatter"], None]]
+ ):
"""Format a string as an error message."""
self.write(message, prefixes=(self.fg("red"), self.bold, "!!! ", self.reset))
- def warn(self, message):
+ def warn(
+ self, message: typing.Union[None, str, typing.Callable[["Formatter"], None]]
+ ):
"""Format a string as a warning message."""
self.write(message, prefixes=(self.fg("yellow"), self.bold, "*** ", self.reset))
- def title(self, string):
+ def title(
+ self, string: typing.Union[None, str, typing.Callable[["Formatter"], None]]
+ ):
"""Set the title to string"""
def flush(self):
@@ -125,7 +136,9 @@ class PlainTextFormatter(Formatter):
bold = underline = reset = ""
- def __init__(self, stream, width=79, encoding=None):
+ def __init__(
+ self, stream: typing.IO, width: int = 79, encoding: typing.Optional[str] = None
+ ):
"""Initialize.
:type stream: file-like object.
@@ -321,7 +334,7 @@ class _BogusTerminfo(ValueError):
class TerminfoUnsupported(Exception):
"""Raised if our terminal type is unsupported."""
- def __init__(self, term):
+ def __init__(self, term: str):
self.term = term
def __str__(self):
@@ -345,11 +358,11 @@ else:
__slots__ = ("mode", "color", "__weakref__")
- def __init__(self, mode, color):
+ def __init__(self, mode: int, color: str):
object.__setattr__(self, "mode", mode)
object.__setattr__(self, "color", color)
- def __call__(self, formatter):
+ def __call__(self, formatter: "TerminfoFormatter"):
if self.color is None:
formatter._current_colors[self.mode] = None
res = formatter._color_reset
@@ -398,7 +411,7 @@ else:
__doc__ = TerminfoCode.__doc__
__slots__ = ()
- def __call__(self, formatter):
+ def __call__(self, formatter: "TerminfoFormatter"):
formatter._modes.add(self)
formatter.stream.write(self.value)
@@ -407,7 +420,7 @@ else:
__doc__ = TerminfoCode.__doc__
__slots__ = ()
- def __call__(self, formatter):
+ def __call__(self, formatter: "TerminfoFormatter"):
formatter._modes.clear()
formatter.stream.write(self.value)
@@ -425,7 +438,12 @@ else:
white=curses.COLOR_WHITE,
)
- def __init__(self, stream, term=None, encoding=None):
+ def __init__(
+ self,
+ stream: typing.IO,
+ term: typing.Optional[str] = None,
+ encoding: typing.Optional[str] = None,
+ ):
"""Initialize.
:type stream: file-like object.
@@ -521,7 +539,7 @@ class ObserverFormatter:
fileno_excepts = (AttributeError, io.UnsupportedOperation)
-def get_formatter(stream, force_color=False):
+def get_formatter(stream: typing.IO, force_color: bool = False):
"""TerminfoFormatter if the stream is a tty, else PlainTextFormatter."""
if TerminfoColor is None:
return PlainTextFormatter(stream)
@@ -547,7 +565,7 @@ def decorate_forced_wrapping(setting=True):
"""Decorator to force a specific line wrapping state for the duration of invocation."""
def wrapped_func(func):
- def f(out, *args, **kwds):
+ def f(out: Formatter, *args, **kwds):
oldwrap = out.wrap
out.wrap = setting
try:
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [gentoo-commits] proj/pkgcore/snakeoil:master commit in: src/snakeoil/
@ 2024-01-26 20:14 Arthur Zamarin
0 siblings, 0 replies; 9+ messages in thread
From: Arthur Zamarin @ 2024-01-26 20:14 UTC (permalink / raw
To: gentoo-commits
commit: 08d724940a92c06e183d112a0377ef32c911a7c3
Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Fri Jan 26 20:14:15 2024 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Fri Jan 26 20:14:15 2024 +0000
URL: https://gitweb.gentoo.org/proj/pkgcore/snakeoil.git/commit/?id=08d72494
start work on 0.10.8
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>
src/snakeoil/__init__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/snakeoil/__init__.py b/src/snakeoil/__init__.py
index 08fa7208..895309fd 100644
--- a/src/snakeoil/__init__.py
+++ b/src/snakeoil/__init__.py
@@ -11,4 +11,4 @@ This library is a bit of a grabbag of the following:
"""
__title__ = "snakeoil"
-__version__ = "0.10.7"
+__version__ = "0.10.8"
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [gentoo-commits] proj/pkgcore/snakeoil:master commit in: src/snakeoil/
@ 2024-01-18 17:15 Arthur Zamarin
0 siblings, 0 replies; 9+ messages in thread
From: Arthur Zamarin @ 2024-01-18 17:15 UTC (permalink / raw
To: gentoo-commits
commit: c6280c1c86b158b1becbefd5c1debc07f5a9d188
Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Thu Jan 18 17:13:35 2024 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Thu Jan 18 17:13:42 2024 +0000
URL: https://gitweb.gentoo.org/proj/pkgcore/snakeoil.git/commit/?id=c6280c1c
start work on 0.10.7
This release might deprecate a lot of functionality which should be
unused. Most likely next release would be 0.11.0
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>
src/snakeoil/__init__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/snakeoil/__init__.py b/src/snakeoil/__init__.py
index 17aa8de2..08fa7208 100644
--- a/src/snakeoil/__init__.py
+++ b/src/snakeoil/__init__.py
@@ -11,4 +11,4 @@ This library is a bit of a grabbag of the following:
"""
__title__ = "snakeoil"
-__version__ = "0.10.6"
+__version__ = "0.10.7"
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [gentoo-commits] proj/pkgcore/snakeoil:master commit in: src/snakeoil/
@ 2024-01-17 8:34 Arthur Zamarin
0 siblings, 0 replies; 9+ messages in thread
From: Arthur Zamarin @ 2024-01-17 8:34 UTC (permalink / raw
To: gentoo-commits
commit: d84df20569840532fb915aa0b6090ee6c7a62af3
Author: Brian Harring <ferringb <AT> gmail <DOT> com>
AuthorDate: Tue Jan 16 04:58:43 2024 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Tue Jan 16 05:00:58 2024 +0000
URL: https://gitweb.gentoo.org/proj/pkgcore/snakeoil.git/commit/?id=d84df205
Add missing DirProxy/GetAttrProxy to klass.__all__
These are public symbols and were supposed to be marked
as such.
Signed-off-by: Brian Harring <ferringb <AT> gmail.com>
src/snakeoil/klass.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/snakeoil/klass.py b/src/snakeoil/klass.py
index 23d6d3c5..08daaab2 100644
--- a/src/snakeoil/klass.py
+++ b/src/snakeoil/klass.py
@@ -28,6 +28,8 @@ __all__ = (
"alias",
"patch",
"SlotsPicklingMixin",
+ "DirProxy",
+ "GetAttrProxy",
)
import inspect
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [gentoo-commits] proj/pkgcore/snakeoil:master commit in: src/snakeoil/
@ 2023-09-09 5:37 Arthur Zamarin
0 siblings, 0 replies; 9+ messages in thread
From: Arthur Zamarin @ 2023-09-09 5:37 UTC (permalink / raw
To: gentoo-commits
commit: 379bf7a6cd7fb7b7c3684c834e20b8d4fe1170ae
Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Wed Aug 30 04:20:08 2023 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Wed Aug 30 04:20:08 2023 +0000
URL: https://gitweb.gentoo.org/proj/pkgcore/snakeoil.git/commit/?id=379bf7a6
mappings: small refactor
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>
src/snakeoil/mappings.py | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/snakeoil/mappings.py b/src/snakeoil/mappings.py
index d4ac221d..f3663571 100644
--- a/src/snakeoil/mappings.py
+++ b/src/snakeoil/mappings.py
@@ -298,7 +298,7 @@ class ProtectedDict(DictMixin):
raise KeyError(key)
def keys(self):
- for k in self.new.keys():
+ for k in self.new:
yield k
for k in self.orig.keys():
if k not in self.blacklist and k not in self.new:
@@ -320,14 +320,14 @@ class ImmutableDict(Mapping):
elif isinstance(data, Mapping):
mapping = data
elif isinstance(data, DictMixin):
- mapping = {k: v for k, v in data.items()}
+ mapping = dict(data.items())
elif data is None:
mapping = {}
else:
try:
- mapping = {k: v for k, v in data}
- except TypeError as e:
- raise TypeError(f"unsupported data format: {e}")
+ mapping = dict(data)
+ except TypeError as exc:
+ raise TypeError(f"unsupported data format: {exc}")
object.__setattr__(self, "_dict", mapping)
def __getitem__(self, key):
@@ -362,8 +362,8 @@ class OrderedFrozenSet(Set):
def __init__(self, iterable=()):
try:
self._dict = ImmutableDict({x: None for x in iterable})
- except TypeError as e:
- raise TypeError("not iterable") from e
+ except TypeError as exc:
+ raise TypeError("not iterable") from exc
def __contains__(self, key):
return key in self._dict
@@ -419,8 +419,8 @@ class OrderedSet(OrderedFrozenSet, MutableSet):
def __init__(self, iterable=()):
try:
self._dict = {x: None for x in iterable}
- except TypeError as e:
- raise TypeError("not iterable") from e
+ except TypeError as exc:
+ raise TypeError("not iterable") from exc
def add(self, value):
self._dict[value] = None
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [gentoo-commits] proj/pkgcore/snakeoil:master commit in: src/snakeoil/
@ 2023-01-20 7:36 Arthur Zamarin
0 siblings, 0 replies; 9+ messages in thread
From: Arthur Zamarin @ 2023-01-20 7:36 UTC (permalink / raw
To: gentoo-commits
commit: 9f1bd128877bc2c316473d34aa4e2cdaec431331
Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Fri Jan 20 07:36:47 2023 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Fri Jan 20 07:36:47 2023 +0000
URL: https://gitweb.gentoo.org/proj/pkgcore/snakeoil.git/commit/?id=9f1bd128
start work on 0.10.6
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>
src/snakeoil/__init__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/snakeoil/__init__.py b/src/snakeoil/__init__.py
index 2009d305..17aa8de2 100644
--- a/src/snakeoil/__init__.py
+++ b/src/snakeoil/__init__.py
@@ -11,4 +11,4 @@ This library is a bit of a grabbag of the following:
"""
__title__ = "snakeoil"
-__version__ = "0.10.5"
+__version__ = "0.10.6"
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [gentoo-commits] proj/pkgcore/snakeoil:master commit in: src/snakeoil/
@ 2022-12-25 18:22 Arthur Zamarin
0 siblings, 0 replies; 9+ messages in thread
From: Arthur Zamarin @ 2022-12-25 18:22 UTC (permalink / raw
To: gentoo-commits
commit: fc6842fea1d87995b97c80b99c97686939d9c388
Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Sun Dec 25 18:22:29 2022 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Sun Dec 25 18:22:29 2022 +0000
URL: https://gitweb.gentoo.org/proj/pkgcore/snakeoil.git/commit/?id=fc6842fe
fix small boolean values typo
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>
src/snakeoil/demandimport.py | 3 ++-
src/snakeoil/demandload.py | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/snakeoil/demandimport.py b/src/snakeoil/demandimport.py
index 0a24ccc5..d95f515e 100644
--- a/src/snakeoil/demandimport.py
+++ b/src/snakeoil/demandimport.py
@@ -56,7 +56,8 @@ def enable():
"""Enable lazy loading for all future module imports."""
if os.environ.get("SNAKEOIL_DEMANDIMPORT", "y").lower() not in (
"n",
- "no" "0",
+ "no",
+ "0",
"false",
):
sys.path_hooks.insert(0, _filefinder)
diff --git a/src/snakeoil/demandload.py b/src/snakeoil/demandload.py
index 3800622f..bfa6dce7 100644
--- a/src/snakeoil/demandload.py
+++ b/src/snakeoil/demandload.py
@@ -313,7 +313,8 @@ def disabled_demand_compile_regexp(name, *args, **kwargs):
if os.environ.get("SNAKEOIL_DEMANDLOAD_DISABLED", "n").lower() in (
"y",
- "yes" "1",
+ "yes",
+ "1",
"true",
):
demandload = disabled_demandload
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [gentoo-commits] proj/pkgcore/snakeoil:master commit in: src/snakeoil/
@ 2022-11-19 13:57 Arthur Zamarin
0 siblings, 0 replies; 9+ messages in thread
From: Arthur Zamarin @ 2022-11-19 13:57 UTC (permalink / raw
To: gentoo-commits
commit: 0ea0ab6271538227f8ca8a1e545b16183e93d122
Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 19 13:57:21 2022 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Sat Nov 19 13:57:21 2022 +0000
URL: https://gitweb.gentoo.org/proj/pkgcore/snakeoil.git/commit/?id=0ea0ab62
start work on 0.10.4
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>
src/snakeoil/__init__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/snakeoil/__init__.py b/src/snakeoil/__init__.py
index 1780dada..636d6636 100644
--- a/src/snakeoil/__init__.py
+++ b/src/snakeoil/__init__.py
@@ -11,4 +11,4 @@ This library is a bit of a grabbag of the following:
"""
__title__ = 'snakeoil'
-__version__ = '0.10.3'
+__version__ = '0.10.4'
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [gentoo-commits] proj/pkgcore/snakeoil:master commit in: src/snakeoil/
@ 2022-11-08 19:39 Arthur Zamarin
0 siblings, 0 replies; 9+ messages in thread
From: Arthur Zamarin @ 2022-11-08 19:39 UTC (permalink / raw
To: gentoo-commits
commit: f3486bd93bb7c3faf0e9da7db360726ba019774a
Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Tue Nov 8 19:39:11 2022 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Tue Nov 8 19:39:29 2022 +0000
URL: https://gitweb.gentoo.org/proj/pkgcore/snakeoil.git/commit/?id=f3486bd9
start work on 0.10.3
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>
src/snakeoil/__init__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/snakeoil/__init__.py b/src/snakeoil/__init__.py
index 4d322886..1780dada 100644
--- a/src/snakeoil/__init__.py
+++ b/src/snakeoil/__init__.py
@@ -11,4 +11,4 @@ This library is a bit of a grabbag of the following:
"""
__title__ = 'snakeoil'
-__version__ = '0.10.2'
+__version__ = '0.10.3'
^ permalink raw reply related [flat|nested] 9+ messages in thread
end of thread, other threads:[~2024-01-26 20:14 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-17 20:39 [gentoo-commits] proj/pkgcore/snakeoil:master commit in: src/snakeoil/ Arthur Zamarin
-- strict thread matches above, loose matches on Subject: below --
2024-01-26 20:14 Arthur Zamarin
2024-01-18 17:15 Arthur Zamarin
2024-01-17 8:34 Arthur Zamarin
2023-09-09 5:37 Arthur Zamarin
2023-01-20 7:36 Arthur Zamarin
2022-12-25 18:22 Arthur Zamarin
2022-11-19 13:57 Arthur Zamarin
2022-11-08 19:39 Arthur Zamarin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox