Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • ketos ketos
  • Project information
    • Project information
    • Activity
    • Labels
    • Planning hierarchy
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 27
    • Issues 27
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • public_projects
  • ketosketos
  • Issues
  • #182

Closed
Open
Created Aug 18, 2022 by Oliver Kirsebom@kirsebomOwner

Warning formats

Currently, ketos issues UserWarnings like this,

import warnings
x = 9
warnings.warn(f"This is my warning {x}", category=UserWarning)

Resulting in output like this,

/home/oliskir/tmp/test.py:3: UserWarning: This is my warning 9
  warnings.warn(f"This is my warning {x}", category=UserWarning)

The warning gives the python file that triggered the warning, the line number, the (formatted) message, and finally also the line of code that issues the warning. Informative, but also difficuly to understand for non developers.

Since these warnings are intended for users (not developers), I would suggest that we adopt a much simpler format that only prints the warning message, and leaves out technical details about where within the code the warning came from.

So, something like this,

def ketos_user_warning_format(message, category, filename, lineno, file=None, line=None):
    return '%s: %s\n' % (category.__name__, message)

warnings.formatwarning = ketos_user_warning_format
 
x = 9
warnings.warn(f"This is my warning {x}", category=UserWarning)

resulting in output like this,

UserWarning: This is my warning 9

@bpadovese , @fsfrazao , your thoughts?

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking