From 7f1a856855e2f7214c507f691a8ee89affc0a527 Mon Sep 17 00:00:00 2001 From: theOehrly <23384863+theOehrly@users.noreply.github.com> Date: Wed, 27 Dec 2023 23:09:52 +0100 Subject: [PATCH] add internal 'short version' and use for user agents --- fastf1/__init__.py | 7 +++++++ fastf1/ergast/interface.py | 4 ++-- fastf1/mvapi/api.py | 4 ++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/fastf1/__init__.py b/fastf1/__init__.py index 782e96e54..609520648 100644 --- a/fastf1/__init__.py +++ b/fastf1/__init__.py @@ -88,6 +88,13 @@ _version = None __version__ = getattr(_version, 'version', 'UNKNOWN') +__version_tuple__ = getattr(_version, 'version_tuple', tuple()) +if __version_tuple__: + # create a short version containing only the public version + __version_short__ = ".".join(str(digit) for digit in __version_tuple__ + if str(digit).isnumeric()) +else: + __version_short__ = __version__ from typing import Dict diff --git a/fastf1/ergast/interface.py b/fastf1/ergast/interface.py index 44519543a..2efe59b0f 100644 --- a/fastf1/ergast/interface.py +++ b/fastf1/ergast/interface.py @@ -2,7 +2,7 @@ import json from typing import List, Literal, Optional, Union -from fastf1 import __version__ +from fastf1 import __version_short__ from fastf1.req import Cache import fastf1.ergast.structure as API @@ -11,7 +11,7 @@ BASE_URL = 'https://ergast.com/api/f1' -HEADERS = {'User-Agent': f'FastF1/{__version__}'} +HEADERS = {'User-Agent': f'FastF1/{__version_short__}'} class ErgastResponseMixin: diff --git a/fastf1/mvapi/api.py b/fastf1/mvapi/api.py index f2b812674..c07864cf4 100644 --- a/fastf1/mvapi/api.py +++ b/fastf1/mvapi/api.py @@ -2,13 +2,13 @@ from typing import Optional -from fastf1 import __version__ +from fastf1 import __version_short__ from fastf1.mvapi.internals import _logger from fastf1.req import Cache PROTO = "https" HOST = "api.multiviewer.app" -HEADERS = {'User-Agent': f'FastF1/{__version__}'} +HEADERS = {'User-Agent': f'FastF1/{__version_short__}'} def _make_url(path: str):