Skip to content

Commit

Permalink
add internal 'short version' and use for user agents
Browse files Browse the repository at this point in the history
  • Loading branch information
theOehrly committed Dec 27, 2023
1 parent a167d86 commit 7f1a856
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
7 changes: 7 additions & 0 deletions fastf1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions fastf1/ergast/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions fastf1/mvapi/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 7f1a856

Please sign in to comment.