def get_version(path) -> str:
    """
    Reads the version field from a package file

    :param path: the path to a valid package.json file
    :return: the version string or "unknown"
    """
    if path and os.path.exists(path):
        with open(path) as pkg:
            package_dict = json.load(pkg)
            version = package_dict.get('version')
    else:
        version = 'not available'
    return version
def get_version ( path ) -> str : if path and os . path . exists ( path ) : with open ( path ) as pkg : package_dict = json . load ( pkg ) version = package_dict . get ( 'version' ) else : version = 'not available' return version
Reads the version field from a package file

    :param path: the path to a valid package.json file
    :return: the version string or "unknown"