import tokenize


def is_comment_token(token1):
    """
    Returns True if the token1 is a comment token, False otherwise.
    Since there is an incompatibility between Python versions,
    this function resolves it.

    Some more information about incompatibility:

    Python 3.6:
    TokenInfo(type=59 (ENCODING), string='utf-8', start=(0, 0), end=(0, 0), line='')
    https://docs.python.org/3.6/library/token.html

    Python 3.7:
    TokenInfo(type=57 (ENCODING), string='utf-8', start=(0, 0), end=(0, 0), line='')
    https://docs.python.org/3.7/library/token.html

    Changed in version 3.7: Added COMMENT, NL and ENCODING tokens.
    """
    assert isinstance(token1, tokenize.TokenInfo)
    result = False

    if "type=54 (COMMENT)" in str(token1):
        # Python 3.4.4
        result = True
    elif "type=57 (COMMENT)" in str(token1):
        # Python 3.6.9
        result = True
    elif "type=55 (COMMENT)" in str(token1):
        # Python 3.7.4
        result = True
    elif " (COMMENT)" in str(token1):
        # a generic solution since Python changes it in every version.
        result = True

    return result