From 5a1e170535202eae20aea6423ac5aaa78fa54efd Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Fri, 20 Jan 2023 10:45:25 -0700 Subject: Minor scanner tweaks Marked a couple of scanner methods that don't use "self" as @staticmethod for consistency. Signed-off-by: Mats Wichmann --- CHANGES.txt | 1 + SCons/Scanner/D.py | 3 ++- SCons/Scanner/JavaTests.py | 4 ++-- SCons/Scanner/LaTeX.py | 3 ++- SCons/Scanner/__init__.py | 6 ++++-- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 2584583..f9e6cb1 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -64,6 +64,7 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER sufficient just to check the build worked. Renamed the fixture dir to follow naming convention in test/MSVC overall, and added a sconstest.skip file, also to follow convention. + - Marked some scanner methods as @staticmethod. RELEASE 4.5.2 - Sun, 21 Mar 2023 14:08:29 -0700 diff --git a/SCons/Scanner/D.py b/SCons/Scanner/D.py index f4366df..9bc608f 100644 --- a/SCons/Scanner/D.py +++ b/SCons/Scanner/D.py @@ -43,7 +43,8 @@ class D(Classic): regex=r'(?:import\s+)([\w\s=,.]+)(?:\s*:[\s\w,=]+)?(?:;)', ) - def find_include(self, include, source_dir, path): + @staticmethod + def find_include(include, source_dir, path): # translate dots (package separators) to slashes inc = include.replace('.', '/') diff --git a/SCons/Scanner/JavaTests.py b/SCons/Scanner/JavaTests.py index cf4ca83..38a4bdb 100644 --- a/SCons/Scanner/JavaTests.py +++ b/SCons/Scanner/JavaTests.py @@ -54,8 +54,8 @@ for fname in subfiles: test.write(fname.split('/'), "\n") class DummyEnvironment(collections.UserDict): - def __init__(self,**kw) -> None: - collections.UserDict.__init__(self) + def __init__(self, **kw) -> None: + super().__init__() self.data.update(kw) self.fs = SCons.Node.FS.FS(test.workpath('')) self['ENV'] = {} diff --git a/SCons/Scanner/LaTeX.py b/SCons/Scanner/LaTeX.py index 6abe736..4412aee 100644 --- a/SCons/Scanner/LaTeX.py +++ b/SCons/Scanner/LaTeX.py @@ -289,7 +289,8 @@ class LaTeX(ScannerBase): return [filename+e for e in self.graphics_extensions] return [filename] - def sort_key(self, include): + @staticmethod + def sort_key(include): return SCons.Node.FS._my_normcase(str(include)) def find_include(self, include, source_dir, path): diff --git a/SCons/Scanner/__init__.py b/SCons/Scanner/__init__.py index c8c2732..61ba8a9 100644 --- a/SCons/Scanner/__init__.py +++ b/SCons/Scanner/__init__.py @@ -415,7 +415,8 @@ class ClassicCPP(Classic): to the constructor must return the leading bracket in group 0, and the contained filename in group 1. """ - def find_include(self, include, source_dir, path): + @staticmethod + def find_include(include, source_dir, path): include = list(map(SCons.Util.to_str, include)) if include[0] == '"': paths = (source_dir,) + tuple(path) @@ -426,7 +427,8 @@ class ClassicCPP(Classic): i = SCons.Util.silent_intern(include[1]) return n, i - def sort_key(self, include): + @staticmethod + def sort_key(include): return SCons.Node.FS._my_normcase(' '.join(include)) # Local Variables: -- cgit v0.12