How to use the vermin.utility.combine_versions 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 / source_visitor.py View on Github external
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)

    for encoding in self.codecs_encodings():
      for encs in CODECS_ENCODINGS:
        if encoding.lower() in encs:
          vers = CODECS_ENCODINGS[encs]
          self.__vvprint("codecs encoding '{}' requires {}".
                         format(encoding, version_strings(vers)), encoding)
          mins = combine_versions(mins, vers)
github netromdk / vermin / vermin / processor.py View on Github external
if ver is not None and ver > (0, 0):
          unique_versions.add(ver)

      # Indent subtext.
      subtext = ""
      if len(proc_res.text) > 0:
        # Keep newlines and throw away dups.
        lines = list(set(proc_res.text.splitlines(True)))
        lines.sort()
        subtext = "\n  " + "  ".join(lines)
        if not subtext.endswith("\n"):
          subtext += "\n"

      vprint("{:<12} {}{}".format(version_strings(proc_res.mins), proc_res.path, subtext))
      try:
        mins = combine_versions(mins, proc_res.mins)
      except InvalidVersionException:
        incomp = True
        print_incomp(proc_res.path)

    pool.close()

    unique_versions = list(unique_versions)
    unique_versions.sort()
    return (mins, incomp, unique_versions, all_backports)
github netromdk / vermin / vermin / source_visitor.py View on Github external
def minimum_versions(self):
    mins = [(0, 0), (0, 0)]

    if self.printv2():
      # Must be like this, not `combine_versions(2.0, None)`, since in py2 all print statements call
      # `visit_Print()` but in py3 it's just a regular function via
      # `Call(func=Name(id="print"..)..)`. Otherwise it will say not compatible with 3 when run on
      # py3. The reason for now using `combine_versions(2.0, 3.0)` is that in py2 we cannot
      # distinguish `print x` from `print(x)` - the first fails in py3 but not the second form.
      mins[0] = (2, 0)

    if self.printv3():
      # print() is used so often that we only want to show it once, and with no line.
      self.__vvprint("print(expr) requires 2+ or 3+", line=-1)
      mins = combine_versions(mins, ((2, 0), (3, 0)))

    if self.format27():
      mins = combine_versions(mins, ((2, 7), (3, 0)))

    if self.longv2():
      mins = combine_versions(mins, ((2, 0), None))

    if self.bytesv3():
      mins = combine_versions(mins, (None, (3, 0)))

    if self.fstrings():
      mins = combine_versions(mins, (None, (3, 6)))

    if self.fstrings_self_doc():
      mins = combine_versions(mins, (None, (3, 8)))
github netromdk / vermin / vermin / source_visitor.py View on Github external
mins = combine_versions(mins, (None, (3, 5)))

    if self.async_generator():
      mins = combine_versions(mins, (None, (3, 6)))

    # NOTE: While async comprehensions and await in comprehensions should be in 3.6, they were first
    # put into 3.7 for some reason!

    if self.async_comprehension():
      mins = combine_versions(mins, (None, (3, 7)))

    if self.await_in_comprehension():
      mins = combine_versions(mins, (None, (3, 7)))

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

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

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

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

    if self.dict_comprehension():
      mins = combine_versions(mins, ((2, 7), (3, 0)))

    if self.infix_matrix_multiplication():
      mins = combine_versions(mins, (None, (3, 5)))