* gnulib-tool.py: Emit libtests in testdirs generated Makefile.am.
@ 2024-04-30 5:28 Collin Funk
2024-04-30 7:44 ` Bruno Haible
0 siblings, 1 reply; 3+ messages in thread
From: Collin Funk @ 2024-04-30 5:28 UTC (permalink / raw
To: bug-gnulib@gnu.org
[-- Attachment #1: Type: text/plain, Size: 292 bytes --]
I just pushed the two patches I sent previously.
Patch 0001 is the fix for missing libtests in testdirs.
Patch 0002 is the type hints for classes.
Hopefully no other bug reports for gnulib-tool.py since the info-gnu
announcement other than the one I just patched is a good sign? :)
Collin
[-- Attachment #2: 0001-gnulib-tool.py-Emit-libtests-in-testdirs-generated-M.patch --]
[-- Type: text/x-patch, Size: 1825 bytes --]
From afca3c77593e3108b0ddfa8ffdf05d7ecfb8137f Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.funk1@gmail.com>
Date: Mon, 29 Apr 2024 22:15:56 -0700
Subject: [PATCH 1/2] gnulib-tool.py: Emit libtests in testdirs generated
Makefile.am.
Reported by Bruno Haible in
<https://lists.gnu.org/archive/html/bug-gnulib/2024-04/msg00463.html>.
* pygnulib/GLTestDir.py (GLTestDir.execute): Modify the GLEmiter's
config variable instead of the GLTestDir's so that it can be accessed
when emitting the Makefile.am.
---
ChangeLog | 9 +++++++++
pygnulib/GLTestDir.py | 3 +--
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index c52dee0b6f..0fdeee8cf9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2024-04-29 Collin Funk <collin.funk1@gmail.com>
+
+ gnulib-tool.py: Emit libtests in testdirs generated Makefile.am.
+ Reported by Bruno Haible in
+ <https://lists.gnu.org/archive/html/bug-gnulib/2024-04/msg00463.html>.
+ * pygnulib/GLTestDir.py (GLTestDir.execute): Modify the GLEmiter's
+ config variable instead of the GLTestDir's so that it can be accessed
+ when emitting the Makefile.am.
+
2024-04-28 Collin Funk <collin.funk1@gmail.com>
doc: Update macro list in gnulib-cache.m4 documentation.
diff --git a/pygnulib/GLTestDir.py b/pygnulib/GLTestDir.py
index 002eb30267..11b067e085 100644
--- a/pygnulib/GLTestDir.py
+++ b/pygnulib/GLTestDir.py
@@ -244,8 +244,7 @@ def execute(self) -> None:
if file.startswith('lib/'):
libtests = True
break
- if libtests:
- self.config.setLibtests(True)
+ self.emitter.config.setLibtests(libtests)
if single_configure:
# Add the dummy module to the main module list if needed.
--
2.44.0
[-- Attachment #3: 0002-gnulib-tool.py-Add-type-hints-to-classes.patch --]
[-- Type: text/x-patch, Size: 9763 bytes --]
From 20061b496065f9a45bddf5a7452c09615f45361c Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.funk1@gmail.com>
Date: Mon, 29 Apr 2024 22:20:31 -0700
Subject: [PATCH 2/2] gnulib-tool.py: Add type hints to classes.
* pygnulib/*.py: Add type hints for all instance and class variables.
* pygnulib/GLMakefileTable.py (GLMakefileTable.__getitem__): Fix return
type hint since the dictionary has str values.
---
ChangeLog | 7 +++++++
pygnulib/GLConfig.py | 2 ++
pygnulib/GLEmiter.py | 3 +++
pygnulib/GLError.py | 7 ++++++-
pygnulib/GLFileSystem.py | 9 +++++++++
pygnulib/GLImport.py | 8 ++++++++
pygnulib/GLMakefileTable.py | 5 ++++-
pygnulib/GLModuleSystem.py | 33 +++++++++++++++++++++++++++++++--
pygnulib/GLTestDir.py | 12 ++++++++++++
9 files changed, 82 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 0fdeee8cf9..bd5bb93c0b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-04-29 Collin Funk <collin.funk1@gmail.com>
+
+ gnulib-tool.py: Add type hints to classes.
+ * pygnulib/*.py: Add type hints for all instance and class variables.
+ * pygnulib/GLMakefileTable.py (GLMakefileTable.__getitem__): Fix return
+ type hint since the dictionary has str values.
+
2024-04-29 Collin Funk <collin.funk1@gmail.com>
gnulib-tool.py: Emit libtests in testdirs generated Makefile.am.
diff --git a/pygnulib/GLConfig.py b/pygnulib/GLConfig.py
index 16fa490fc6..92aa49d700 100644
--- a/pygnulib/GLConfig.py
+++ b/pygnulib/GLConfig.py
@@ -41,6 +41,8 @@ class GLConfig:
By default all attributes are set to empty string, empty list or zero.
The most common value, however, is a None value.'''
+ table: dict[str, Any]
+
def __init__(self,
destdir: str | None = None,
localpath: list[str] | None = None,
diff --git a/pygnulib/GLEmiter.py b/pygnulib/GLEmiter.py
index ed6eae4997..3fbf796aaa 100644
--- a/pygnulib/GLEmiter.py
+++ b/pygnulib/GLEmiter.py
@@ -98,6 +98,9 @@ def _eliminate_NMD(snippet: str, automake_subdir: bool) -> str:
class GLEmiter:
'''This class is used to emit the contents of necessary files.'''
+ info: GLInfo
+ config: GLConfig
+
def __init__(self, config: GLConfig) -> None:
'''Create GLEmiter instance.'''
self.info = GLInfo()
diff --git a/pygnulib/GLError.py b/pygnulib/GLError.py
index 184d65f59c..4288820c97 100644
--- a/pygnulib/GLError.py
+++ b/pygnulib/GLError.py
@@ -19,6 +19,7 @@
# Define global imports
#===============================================================================
import os
+from typing import Any
#===============================================================================
@@ -27,7 +28,11 @@
class GLError(Exception):
'''Exception handler for pygnulib classes.'''
- def __init__(self, errno: int, errinfo: str | float | None = None) -> None:
+ errno: int
+ errinfo: Any
+ args: tuple[int, Any]
+
+ def __init__(self, errno: int, errinfo: Any = None) -> None:
'''Each error has following parameters:
errno: code of error; used to catch error type
1: file does not exist in GLFileSystem: <file>
diff --git a/pygnulib/GLFileSystem.py b/pygnulib/GLFileSystem.py
index 028ba3885e..f8b7f54ab3 100644
--- a/pygnulib/GLFileSystem.py
+++ b/pygnulib/GLFileSystem.py
@@ -46,6 +46,8 @@ class GLFileSystem:
Its main method lookup(file) is used to find file in these directories or
combine it using Linux 'patch' utility.'''
+ config: GLConfig
+
def __init__(self, config: GLConfig) -> None:
'''Create new GLFileSystem instance. The only argument is localpath,
which can be an empty list.'''
@@ -139,6 +141,13 @@ def shouldLink(self, original: str, lookedup: str) -> bool:
class GLFileAssistant:
'''GLFileAssistant is used to help with file processing.'''
+ original: str | None
+ rewritten: str | None
+ added: list[str]
+ config: GLConfig
+ transformers: dict[str, tuple[re.Pattern, str] | None]
+ filesystem: GLFileSystem
+
def __init__(self, config: GLConfig, transformers: dict[str, tuple[re.Pattern, str] | None] | None = None) -> None:
'''Create GLFileAssistant instance.
diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py
index 47c0e83555..63877342d2 100644
--- a/pygnulib/GLImport.py
+++ b/pygnulib/GLImport.py
@@ -60,6 +60,14 @@ class GLImport:
scripts. However, if user needs just to use power of gnulib-tool, this class
is a very good choice.'''
+ mode: int
+ config: GLConfig
+ cache: GLConfig
+ emitter: GLEmiter
+ modulesystem: GLModuleSystem
+ moduletable: GLModuleTable
+ makefiletable: GLMakefileTable
+
def __init__(self, config: GLConfig, mode: int) -> None:
'''Create GLImport instance.
The first variable, mode, must be one of the values of the MODES dict
diff --git a/pygnulib/GLMakefileTable.py b/pygnulib/GLMakefileTable.py
index 16e22f914f..efd276d20c 100644
--- a/pygnulib/GLMakefileTable.py
+++ b/pygnulib/GLMakefileTable.py
@@ -33,6 +33,9 @@ class GLMakefileTable:
An edit may be removed; this is done by removing its 'var' key but
keeping it in the list. Removed edits must be ignored.'''
+ config: GLConfig
+ table: list[dict[str, str | bool]]
+
def __init__(self, config: GLConfig) -> None:
'''Create GLMakefileTable instance.'''
if type(config) is not GLConfig:
@@ -41,7 +44,7 @@ def __init__(self, config: GLConfig) -> None:
self.config = config
self.table = []
- def __getitem__(self, y: int) -> dict[str, bool]:
+ def __getitem__(self, y: int) -> dict[str, str | bool]:
'''x.__getitem__(y) = x[y]'''
if type(y) is not int:
raise TypeError('indices must be integers, not %s'
diff --git a/pygnulib/GLModuleSystem.py b/pygnulib/GLModuleSystem.py
index ba1c57eb3f..a5afb5af6f 100644
--- a/pygnulib/GLModuleSystem.py
+++ b/pygnulib/GLModuleSystem.py
@@ -24,6 +24,7 @@
import hashlib
import subprocess as sp
from collections import defaultdict
+from typing import Any, ClassVar
from .constants import (
DIRS,
ENCS,
@@ -46,6 +47,9 @@ class GLModuleSystem:
'''GLModuleSystem is used to operate with module system using dynamic
searching and patching.'''
+ config: GLConfig
+ filesystem: GLFileSystem
+
def __init__(self, config: GLConfig) -> None:
'''Create new GLModuleSystem instance. Some functions use GLFileSystem class
to look up a file in localpath or gnulib directories, or combine it through
@@ -155,14 +159,25 @@ class GLModule:
path. GLModule can get all information about module, get its dependencies,
files, etc.'''
- section_label_pattern = \
+ # Regular expression matching the start of a section in the module description.
+ section_label_pattern: ClassVar[re.Pattern] = \
re.compile(r'^(Description|Comment|Status|Notice|Applicability|'
+ r'Files|Depends-on|configure\.ac-early|configure\.ac|'
+ r'Makefile\.am|Include|Link|License|Maintainer):$',
re.M)
# List of characters allowed in shell identifiers.
- shell_id_chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_'
+ shell_id_chars: ClassVar[str] = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_'
+
+ cache: dict[str, Any]
+ content: str
+ name: str
+ path: str
+ patched: bool
+ config: GLConfig
+ filesystem: GLFileSystem
+ modulesystem: GLModuleSystem
+ sections: dict[str, str]
def __init__(self, config: GLConfig, name: str, path: str, patched: bool = False) -> None:
'''Create new GLModule instance. Arguments are:
@@ -683,6 +698,20 @@ def getMaintainer(self) -> str:
class GLModuleTable:
'''GLModuleTable is used to work with the list of the modules.'''
+ dependers: defaultdict[GLModule, set[GLModule]]
+ conditionals: dict[tuple[GLModule, GLModule], str | bool]
+ unconditionals: set[GLModule]
+ base_modules: list[GLModule]
+ main_modules: list[GLModule]
+ tests_modules: list[GLModule]
+ final_modules: list[GLModule]
+ config: GLConfig
+ filesystem: GLFileSystem
+ modulesystem: GLModuleSystem
+ inc_all_direct_tests: bool
+ inc_all_indirect_tests: bool
+ avoids: set[GLModule]
+
def __init__(self, config: GLConfig, inc_all_direct_tests: bool, inc_all_indirect_tests: bool) -> None:
'''Create new GLModuleTable instance. If modules are specified, then add
every module from iterable as unconditional module. If avoids is specified,
diff --git a/pygnulib/GLTestDir.py b/pygnulib/GLTestDir.py
index 11b067e085..688224cdce 100644
--- a/pygnulib/GLTestDir.py
+++ b/pygnulib/GLTestDir.py
@@ -91,6 +91,14 @@ class GLTestDir:
'''GLTestDir class is used to create a scratch package with the given
list of the modules.'''
+ config: GLConfig
+ testdir: str
+ emitter: GLEmiter
+ filesystem: GLFileSystem
+ modulesystem: GLModuleSystem
+ assistant: GLFileAssistant
+ makefiletable: GLMakefileTable
+
def __init__(self, config: GLConfig, testdir: str) -> None:
'''Create new GLTestDir instance.'''
if type(config) is not GLConfig:
@@ -845,6 +853,10 @@ class GLMegaTestDir:
'''GLMegaTestDir class is used to create a mega scratch package with the
given modules one by one and all together.'''
+ config: GLConfig
+ megatestdir: str
+ modulesystem: GLModuleSystem
+
def __init__(self, config: GLConfig, megatestdir: str) -> None:
'''Create new GLTestDir instance.'''
if type(config) is not GLConfig:
--
2.44.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: gnulib-tool.py: Emit libtests in testdirs generated Makefile.am.
2024-04-30 5:28 gnulib-tool.py: Emit libtests in testdirs generated Makefile.am Collin Funk
@ 2024-04-30 7:44 ` Bruno Haible
2024-04-30 8:24 ` Collin Funk
0 siblings, 1 reply; 3+ messages in thread
From: Bruno Haible @ 2024-04-30 7:44 UTC (permalink / raw
To: bug-gnulib; +Cc: Collin Funk
Collin Funk wrote:
> Hopefully no other bug reports for gnulib-tool.py since the info-gnu
> announcement other than the one I just patched is a good sign? :)
Yes, it's a good sign, and most probably a consequence of the testing
with various packages [1][2] that we did.
Bruno
[1] https://lists.gnu.org/archive/html/bug-gnulib/2024-04/msg00101.html
[2] https://lists.gnu.org/archive/html/bug-gnulib/2024-04/msg00171.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: gnulib-tool.py: Emit libtests in testdirs generated Makefile.am.
2024-04-30 7:44 ` Bruno Haible
@ 2024-04-30 8:24 ` Collin Funk
0 siblings, 0 replies; 3+ messages in thread
From: Collin Funk @ 2024-04-30 8:24 UTC (permalink / raw
To: Bruno Haible, bug-gnulib
Hi Bruno,
On 4/30/24 12:44 AM, Bruno Haible wrote:
> Yes, it's a good sign, and most probably a consequence of the testing
> with various packages [1][2] that we did.
And the test suite that you wrote. Many thanks for working on that for
me.
Also, thanks for testing all the projects who use cvs. I never learned
how to use it haha.
Collin
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-04-30 8:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-30 5:28 gnulib-tool.py: Emit libtests in testdirs generated Makefile.am Collin Funk
2024-04-30 7:44 ` Bruno Haible
2024-04-30 8:24 ` Collin Funk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).