Skip to content

Code Quality: Improve dashboard code and fix warnings#155

Open
mkh-user wants to merge 1 commit into
pyfenn:mainfrom
mkh-user:codequality/dashboard
Open

Code Quality: Improve dashboard code and fix warnings#155
mkh-user wants to merge 1 commit into
pyfenn:mainfrom
mkh-user:codequality/dashboard

Conversation

@mkh-user

Copy link
Copy Markdown

Summary

No behavior change or fix (tested), just fixes warnings like unused argument and shadowed name, and a small grammar fix. An unnecessary convert v if v is not None else "" was changed to v, and the misleading comment associated with it was corrected. Additionally, the unused debug parameter in dashboard/app.run() was marked for separate correction.

Details

Performed improvements:

  • Prefixing with underscore to suppress unused variable warning
  • Renaming to avoid shadowing
  • Docstrings grammar fix
  • Renaming import to follow naming conventions
  • Converting to static method
  • Removing redundant variable initialization
  • Removing redundant parentheses in return statement
  • Remove sentinel string replacement for None in sort key, rely on tuple ordering, Also clarify type-mismatch limits

Follow-Ups

  • fenn/dashboard/app.py:335-347:
+# TODO: Use 'debug' in logger
def run(
    host: str = "127.0.0.1", port: int = 5000, debug: bool = False, log_dirs=None
) -> None:
    """Configure and start the dashboard server."""
    if log_dirs:
        scanner.add_dirs(log_dirs)
    logging.getLogger("werkzeug").setLevel(logging.ERROR)
    app.logger.setLevel(logging.ERROR)
    print(f"Fenn dashboard started at http://{host}:{port}")
    from werkzeug.serving import make_server
    make_server(host, port, app).serve_forever()

debug parameter is not used here, marked to catch later, proposed usage is:

log_level = logging.DEBUG if debug else logging.ERROR
logging.getLogger("werkzeug").setLevel(log_level)
app.logger.setLevel(log_level)

Is this change appropriate to create another PR for it?

Code quality improve for dashboard:
- Add '_' prefix to unused arguments
- Rename shadowed names (internals)
- Mark unused 'app.run(debug)' as TODO (follow-up)
- Improve grammar in docs
- Convert simple functions to static methods
- Cleanup sorting logic and clarify its real behavior
@ApusBerliozi ApusBerliozi requested a review from blkdmr June 10, 2026 06:34
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.

1 participant