Skip to content

Fix broken logging integration in __init__.py and __main__.py#3

Merged
Theblackdragon5 merged 2 commits intomainfrom
copilot/fix-logging-functions
Mar 28, 2026
Merged

Fix broken logging integration in __init__.py and __main__.py#3
Theblackdragon5 merged 2 commits intomainfrom
copilot/fix-logging-functions

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 28, 2026

The logging additions introduced two IndentationErrors (preventing import entirely) and a NameError at runtime from a conditionally-defined logger used at module scope.

AOS/__init__.py

  • Removed two redundant import logging statements (was imported 3×)
  • Fixed misaligned indentation in except Exception as c_exception: block — il.cprint() and logger.warning() had 20/16 spaces instead of 12, causing an IndentationError

AOS/__main__.py

  • Removed from AOS.utils import logging as logging — this shadowed stdlib logging with the AOS utility module (which only exposes process_command, not getLogger)
  • Moved logger = logging.getLogger(__name__) to module level — it was scoped inside if var.logging_location is None:, so logger.* calls outside that branch raised NameError
  • Replaced import logging as Pythonlogging alias with plain import logging; updated the one call site accordingly
  • Fixed if "--nobox" not in argv: body — il.box() and logger.info() were not indented into the block, causing IndentationError
Original prompt

Das Programm funktioniert nicht mehr, durch die Logging Funktionen. Mach es wieder einsatzbereit.


📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

Agent-Logs-Url: https://github.com/administer-org/aos/sessions/c3c1a37f-bfcd-4c27-9749-295b1bc9002c

Co-authored-by: Theblackdragon5 <130586375+Theblackdragon5@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix program functionality issues caused by logging functions Fix broken logging integration in __init__.py and __main__.py Mar 28, 2026
Copilot AI requested a review from Theblackdragon5 March 28, 2026 16:57
@Theblackdragon5 Theblackdragon5 marked this pull request as ready for review March 28, 2026 17:02
Copilot AI review requested due to automatic review settings March 28, 2026 17:02
@Theblackdragon5 Theblackdragon5 merged commit 108f63b into main Mar 28, 2026
3 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Restores AOS startup/CLI usability by fixing syntax/runtime issues introduced by recent logging changes (indentation errors preventing import and a conditionally-defined logger causing runtime failures).

Changes:

  • Fixes indentation issues that caused IndentationError in AOS/__init__.py and AOS/__main__.py.
  • Removes accidental shadowing of stdlib logging and ensures logger is defined at module scope in AOS/__main__.py.
  • Cleans up redundant logging imports and makes logging configuration/logger initialization consistent in AOS/__init__.py.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
AOS/__main__.py Fixes logging import/shadowing, ensures logger is always defined, and repairs indentation in the --nobox block.
AOS/__init__.py Removes redundant imports and fixes indentation in exception fallback while centralizing logging setup.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +16 to 21
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

from sys import argv
from pathlib import Path
from typing import Optional
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logging.basicConfig(...) and logger = ... are executed before several remaining imports (from sys import argv, from pathlib import Path, etc.), which will trigger flake8/ruff E402 (“module level import not at top of file”). Consider moving these remaining imports above the logging configuration, or moving the logging configuration below all imports so the import block stays contiguous.

Copilot uses AI. Check for mistakes.
Comment on lines +14 to 17
import logging

logger = logging.getLogger(__name__)
console = Console()
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pyproject.toml defines the console script entrypoint as AOS.__main__:main, but this module currently has no main() function, and it executes CLI logic at import time. This will make aos fail with AttributeError: module 'AOS.__main__' has no attribute 'main'. Add a main() function and move the module-level CLI logic into it (optionally calling it under if __name__ == "__main__":).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants