From 316d99a86e1f94df873828f791e860b10599daa8 Mon Sep 17 00:00:00 2001 From: Cornelius Kirchhoff Date: Thu, 19 Dec 2024 10:07:12 +0100 Subject: [PATCH 1/4] update pre-commit hooks --- .pre-commit-config.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a0b985d..ba20825 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,17 +16,17 @@ repos: args: [ '--quiet' ] - repo: https://github.com/asottile/pyupgrade - rev: v2.31.0 + rev: v3.19.1 hooks: - id: pyupgrade - repo: https://github.com/Lucas-C/pre-commit-hooks - rev: v1.1.10 + rev: v1.5.5 hooks: - id: remove-tabs - repo: https://github.com/commitizen-tools/commitizen - rev: v2.20.4 + rev: v4.1.0 hooks: - id: commitizen stages: [ commit-msg ] @@ -40,7 +40,7 @@ repos: - id: check-executables-have-shebangs - id: fix-encoding-pragma - repo: https://github.com/pre-commit/pygrep-hooks - rev: v1.9.0 # Use the ref you want to point at + rev: v1.10.0 # Use the ref you want to point at hooks: - id: rst-backticks - id: rst-directive-colons @@ -51,7 +51,7 @@ repos: - id: rst-linter - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.7.2 + rev: v0.8.3 hooks: # Run the linter. - id: ruff From 3190cfaf9fd2832d269879b47ce33d82f05c8b73 Mon Sep 17 00:00:00 2001 From: Cornelius Kirchhoff Date: Thu, 19 Dec 2024 10:12:38 +0100 Subject: [PATCH 2/4] Small fixes * Remove prints * Remove fix-encoding-pragma pre-commit hook --- .pre-commit-config.yaml | 1 - src/tfutility/core/tffile.py | 7 ++----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ba20825..43d92fe 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -38,7 +38,6 @@ repos: - id: end-of-file-fixer - id: check-docstring-first - id: check-executables-have-shebangs - - id: fix-encoding-pragma - repo: https://github.com/pre-commit/pygrep-hooks rev: v1.10.0 # Use the ref you want to point at hooks: diff --git a/src/tfutility/core/tffile.py b/src/tfutility/core/tffile.py index 7290c26..9f2868d 100644 --- a/src/tfutility/core/tffile.py +++ b/src/tfutility/core/tffile.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import pathlib import re from collections import namedtuple @@ -200,7 +199,6 @@ def has_decorator(self, name: str) -> bool: :return: True if the block has a decorator with the given name, False otherwise :rtype: bool """ - print("blubl" * 10) if self._decorators is None: self._decorators = self._find_decorators() for dec in self._decorators: @@ -215,11 +213,9 @@ def _find_decorators(self): :return: A list of decorators found above this block :rtype: list[TfUtilDecorator] """ - print("hiii" * 100) line_nr = self._start_line - 2 decorator_list = [] while self.tffile.lines[line_nr].strip().startswith("# @"): - print(self.tffile.lines[line_nr]) found_decorator = self.tffile.lines[line_nr].strip() result = TfBlock.DECORATOR_REGEX.fullmatch(found_decorator) decorator_list.append( @@ -234,6 +230,7 @@ class TfFile: def __init__(self, path: pathlib.Path, autoparse=True): self.path = path self._blocks = None + print(path) self._tf_file = self.read_tf(path) if autoparse: self.parse() @@ -285,7 +282,7 @@ def _extract_blocks(self, blockdata: dict, name: str): ): elem_names = [key for key in blockdata.keys() if not key.startswith("__")] - if len(elem_names) > 1: + if len(elem_names) < 1: new_name = "" else: new_name = elem_names[0] From 9dd0eec86b9aed340d53a3bba2e786a79b592b42 Mon Sep 17 00:00:00 2001 From: Cornelius Kirchhoff Date: Thu, 19 Dec 2024 10:18:35 +0100 Subject: [PATCH 3/4] Remove prints and apply pre-commit rule --- src/tfutility/controllers/blockdate.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/tfutility/controllers/blockdate.py b/src/tfutility/controllers/blockdate.py index 304015e..5c8ee12 100644 --- a/src/tfutility/controllers/blockdate.py +++ b/src/tfutility/controllers/blockdate.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import sys from datetime import datetime, timedelta @@ -54,14 +53,10 @@ def new_block(self, options, block): if not options.expire_after: if dec.parameter("expire"): - print("HIII") - dec_date_expire = datetime.strptime( dec.parameter("expire"), "%d-%m-%Y" ) if now > dec_date_expire: - print("FOOOHIII") - self._error = True self.get_logger().error( "{} Block expired in file: {}:{}".format( @@ -79,7 +74,7 @@ def new_block(self, options, block): def handle(self, options): self._error = False - results = super(BlockDateHandler, self).handle(options) + results = super().handle(options) tf_files = self.get_file_list(options.paths) From ecae3bf4d59d5d2592707ac396a5d5cbad024110 Mon Sep 17 00:00:00 2001 From: Cornelius Kirchhoff Date: Thu, 19 Dec 2024 10:22:04 +0100 Subject: [PATCH 4/4] fix: ignore directories with dot --- src/tfutility/core/tfpaths.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/tfutility/core/tfpaths.py b/src/tfutility/core/tfpaths.py index 2900e49..daa9d07 100644 --- a/src/tfutility/core/tfpaths.py +++ b/src/tfutility/core/tfpaths.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import argparse import pathlib @@ -19,7 +18,7 @@ def add_arguments(self, parser: argparse.ArgumentParser) -> argparse.ArgumentPar :return: Tthe argument parser enriched with arguments :rtype: argparse.ArgumentParser """ - parser = super(TfPaths, self).add_arguments(parser) + parser = super().add_arguments(parser) parser.add_argument( "paths", nargs="+", @@ -54,7 +53,11 @@ def get_file_list(self, paths: list[pathlib.Path]) -> list[pathlib.Path]: """ file_list = [] for p in paths: - file_list += self._get_files_from_path(p) + file_list += [ + f + for f in self._get_files_from_path(p) + if "/." not in f.absolute().as_posix() + ] if len(file_list) <= 0: self.get_logger().warning(