Skip to content

fix return type of client.CycloneDxCmd.execute and use of exit #325

Closed

Description

@jkowalleck

the return type of cyclonedx_py.client.CycloneDxCmd.execute is currently None.
unfortunately this is not true. There are cases in which the method will never return, but exit python. there are other cases when the method returns. Therefore the return is sometimes typing.NoReturn

motivation:

  • be able to write unit tests for cyclonedx_py.client.CycloneDxCmd.execute
  • be able to catch raise conditions/exit codes in unit tests.

Proposal:

  • change the method to a bare state where it will always exit, but never return.
    therefore use sys.exit() and return type of typing.NoReturn
    calling methods - like unit tests - could catch the SystemExit exception and work with it if needed/
  • cyclonedx_py.client.main() should have a return type of NoReturn as well.
  • do not use exit but sys.exit - with proper ext message or raise condition.

acc crit:

  • all methods & functions of cyclonedx_py.client either return or exit. they may throw exceptions in addition.

alternative proposal or an addition:

  • implementation detail: use click for arg parsing and CLI foo

Activity

  1. added
    enhancement
    QA
    bug
    on Mar 3, 2022
  2. changed the title [-]fix return type of `client.CycloneDxCmd.execute`[/-] [+]fix return type of `client.CycloneDxCmd.execute` and use of `exit`[/+] on Mar 3, 2022
  3. added this to the 4.0.0 milestone on Oct 24, 2023
  4. self-assigned this
    on Nov 14, 2023
  5. jkowalleck commented on Dec 25, 2023

    @jkowalleck
    MemberAuthor

    v4 will remove this API.
    fixed via #605

  6. jkowalleck commented on Dec 25, 2023

    @jkowalleck
    MemberAuthor

    This feature will be part of the next/upcoming major release.
    Changelog: see #605
    Install via: pip install cyclonedx-bom==4.0.0rc1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

QAbugenhancement

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions