Skip to content

Use Case: Introduce a "isvalid()" function to check for valid semver version #208

@tomschr

Description

@tomschr

Situation

At the moment, we don't have a function which checks a version string and returns True/False values.

The user is forced to parse the version string and have to check for a ValueError exception:

import semver

try:
   version = "..."
   semver.VersionInfo.parse(version)
   # if we are still here, then it's true
except ValueError:
   # seems, version wasn't a good semver version

I think, this is a bit cumbersome.

Proposed Solution

It would be nice if we could do something like this:

version = "..."
if semver.VersionInfo.isvalid(version):
   print("Good version :-)!")
else:
  print("Bad version :-(")

Open questions:

  1. Is this use case useful?
  2. Currently, I see semver.VersionInfo.isvalid() as a classmethod. Should we better place this function outside the class, like semver.isvalid()?
  3. Regardless of the location, is the name ok? It resembles the is...() functions from the str datatype.

Metadata

Metadata

Assignees

Labels

EnhancementNot a bug, but increases or improves in value, quality, desirability, or attractivenessQuestionUnclear or open issue subject for debate

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy