How to use the vermin.utility.version_strings function in vermin

To help you get started, we’ve selected a few vermin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github netromdk / vermin / vermin / main.py View on Github external
print("If so, try using the following for better results: {}\n".
          format("".join([" --backport {}".format(n) for n in unique_bps]).strip()))

  if len(reqs) > 0:
    print("Minimum required versions: {}".format(version_strings(reqs)))

  # Don't show incompatible versions when -i is given, unless there are no non-incompatible versions
  # found then we need must show the incompatible versions - nothing will be shown otherwise. That
  # case is when both py2 and py3 incompatibilities were found - in which case `incomps = [2, 3]`
  # and `reqs = []`. But if `incomps = [2]` and `reqs = [3.4]`, for instance, then it makes sense
  # not to show incompatible versions with -i specified.
  if len(incomps) > 0 and (not config.ignore_incomp() or len(reqs) == 0):
    print("Incompatible versions:     {}".format(version_strings(incomps)))

  if args["versions"] and len(unique_versions) > 0:
    print("Version range:             {}".format(version_strings(unique_versions)))

  if len(targets) > 0:
    if not (len(reqs) == len(targets) and
            all(((exact and target == req) or (not exact and target >= req)) for
                ((exact, target), req) in zip(targets, reqs))):
      vers = ["{}{}".format(dotted_name(t), "-" if not e else "") for (e, t) in targets]
      print("Target versions not met:   {}".format(version_strings(vers)))
      if len(targets) < len(reqs):
        print("Note: Number of specified targets ({}) doesn't match number of detected minimum "
              "versions ({}).".format(len(targets), len(reqs)))
      sys.exit(1)

  sys.exit(0)
github netromdk / vermin / vermin / main.py View on Github external
# found then we need must show the incompatible versions - nothing will be shown otherwise. That
  # case is when both py2 and py3 incompatibilities were found - in which case `incomps = [2, 3]`
  # and `reqs = []`. But if `incomps = [2]` and `reqs = [3.4]`, for instance, then it makes sense
  # not to show incompatible versions with -i specified.
  if len(incomps) > 0 and (not config.ignore_incomp() or len(reqs) == 0):
    print("Incompatible versions:     {}".format(version_strings(incomps)))

  if args["versions"] and len(unique_versions) > 0:
    print("Version range:             {}".format(version_strings(unique_versions)))

  if len(targets) > 0:
    if not (len(reqs) == len(targets) and
            all(((exact and target == req) or (not exact and target >= req)) for
                ((exact, target), req) in zip(targets, reqs))):
      vers = ["{}{}".format(dotted_name(t), "-" if not e else "") for (e, t) in targets]
      print("Target versions not met:   {}".format(version_strings(vers)))
      if len(targets) < len(reqs):
        print("Note: Number of specified targets ({}) doesn't match number of detected minimum "
              "versions ({}).".format(len(targets), len(reqs)))
      sys.exit(1)

  sys.exit(0)
github netromdk / vermin / vermin / main.py View on Github external
unique_bps = backports - config.backports()
  if len(unique_bps) > 0 and not no_tips:
    print("Tip: You're using potentially backported modules: {}".format(", ".join(unique_bps)))
    print("If so, try using the following for better results: {}\n".
          format("".join([" --backport {}".format(n) for n in unique_bps]).strip()))

  if len(reqs) > 0:
    print("Minimum required versions: {}".format(version_strings(reqs)))

  # Don't show incompatible versions when -i is given, unless there are no non-incompatible versions
  # found then we need must show the incompatible versions - nothing will be shown otherwise. That
  # case is when both py2 and py3 incompatibilities were found - in which case `incomps = [2, 3]`
  # and `reqs = []`. But if `incomps = [2]` and `reqs = [3.4]`, for instance, then it makes sense
  # not to show incompatible versions with -i specified.
  if len(incomps) > 0 and (not config.ignore_incomp() or len(reqs) == 0):
    print("Incompatible versions:     {}".format(version_strings(incomps)))

  if args["versions"] and len(unique_versions) > 0:
    print("Version range:             {}".format(version_strings(unique_versions)))

  if len(targets) > 0:
    if not (len(reqs) == len(targets) and
            all(((exact and target == req) or (not exact and target >= req)) for
                ((exact, target), req) in zip(targets, reqs))):
      vers = ["{}{}".format(dotted_name(t), "-" if not e else "") for (e, t) in targets]
      print("Target versions not met:   {}".format(version_strings(vers)))
      if len(targets) < len(reqs):
        print("Note: Number of specified targets ({}) doesn't match number of detected minimum "
              "versions ({}).".format(len(targets), len(reqs)))
      sys.exit(1)

  sys.exit(0)
github netromdk / vermin / vermin / source_visitor.py View on Github external
self.__vvprint("'{}' requires {}".format(mod, version_strings(vers)), mod)
        mins = combine_versions(mins, vers)

    mems = self.members()
    for mem in mems:
      if mem in self.__mod_mem_reqs_rules:
        vers = self.__mod_mem_reqs_rules[mem]
        self.__vvprint("'{}' requires {}".format(mem, version_strings(vers)), mem)
        mins = combine_versions(mins, vers)

    kwargs = self.kwargs()
    for fn_kw in kwargs:
      if fn_kw in KWARGS_REQS:
        vers = KWARGS_REQS[fn_kw]
        self.__vvprint("'{}({})' requires {}".format(fn_kw[0], fn_kw[1],
                                                     version_strings(vers)), fn_kw)
        mins = combine_versions(mins, vers)

    return mins
github netromdk / vermin / vermin / source_visitor.py View on Github external
mins = combine_versions(mins, (None, (3, 5)))

    if self.continue_in_finally():
      mins = combine_versions(mins, (None, (3, 8)))

    if self.modular_inverse_pow():
      mins = combine_versions(mins, (None, (3, 8)))

    if self.with_statement():
      mins = combine_versions(mins, ((2, 5), (3, 0)))

    for directive in self.strftime_directives():
      if directive in STRFTIME_REQS:
        vers = STRFTIME_REQS[directive]
        self.__vvprint("strftime directive '{}' requires {}".
                       format(directive, version_strings(vers)), directive)
        mins = combine_versions(mins, vers)

    for typecode in self.array_typecodes():
      if typecode in ARRAY_TYPECODE_REQS:
        vers = ARRAY_TYPECODE_REQS[typecode]
        self.__vvprint("array typecode '{}' requires {}".
                       format(typecode, version_strings(vers)), typecode)
        mins = combine_versions(mins, vers)

    for name in self.codecs_error_handlers():
      if name in CODECS_ERROR_HANDLERS:
        vers = CODECS_ERROR_HANDLERS[name]
        self.__vvprint("codecs error handler name '{}' requires {}".
                       format(name, version_strings(vers)), name)
        mins = combine_versions(mins, vers)
github netromdk / vermin / vermin / main.py View on Github external
reqs.append(ver)

  if len(reqs) == 0 and len(incomps) == 0:
    print("No known reason found that it will not work with 2+ and 3+.")
    print("Please report if it does not: https://github.com/netromdk/vermin/issues/")
    if config.lax_mode() and not no_tips:
      print("Tip: Try without using lax mode for more thorough analysis.")

  unique_bps = backports - config.backports()
  if len(unique_bps) > 0 and not no_tips:
    print("Tip: You're using potentially backported modules: {}".format(", ".join(unique_bps)))
    print("If so, try using the following for better results: {}\n".
          format("".join([" --backport {}".format(n) for n in unique_bps]).strip()))

  if len(reqs) > 0:
    print("Minimum required versions: {}".format(version_strings(reqs)))

  # Don't show incompatible versions when -i is given, unless there are no non-incompatible versions
  # found then we need must show the incompatible versions - nothing will be shown otherwise. That
  # case is when both py2 and py3 incompatibilities were found - in which case `incomps = [2, 3]`
  # and `reqs = []`. But if `incomps = [2]` and `reqs = [3.4]`, for instance, then it makes sense
  # not to show incompatible versions with -i specified.
  if len(incomps) > 0 and (not config.ignore_incomp() or len(reqs) == 0):
    print("Incompatible versions:     {}".format(version_strings(incomps)))

  if args["versions"] and len(unique_versions) > 0:
    print("Version range:             {}".format(version_strings(unique_versions)))

  if len(targets) > 0:
    if not (len(reqs) == len(targets) and
            all(((exact and target == req) or (not exact and target >= req)) for
                ((exact, target), req) in zip(targets, reqs))):