Skip to content

Commit

Permalink
Use methodtools.lru_cache instead of functools.lru_cache in class…
Browse files Browse the repository at this point in the history
… methods (apache#37757)

* Use `methodtools.lru_cache` instead of `functools.lru_cache` in class methods

* Rename pre-commit script
  • Loading branch information
Taragolis authored and potiuk committed Apr 3, 2024
1 parent c65b083 commit 0574e7c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,7 @@ repos:
entry: "^\\s*from re\\s|^\\s*import re\\s"
pass_filenames: true
files: \.py$
exclude: ^airflow/providers|^dev/.*\.py$|^scripts/.*\.py$|^tests/|^\w+_tests/|^docs/.*\.py$|^airflow/utils/helpers.py$
exclude: ^airflow/providers|^dev/.*\.py$|^scripts/.*\.py$|^tests/|^\w+_tests/|^docs/.*\.py$|^airflow/utils/helpers.py$|^hatch_build.py$
- id: check-deferrable-default-value
name: Check default value of deferrable attribute
language: python
Expand Down
16 changes: 16 additions & 0 deletions hatch_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import json
import logging
import os
import re
import sys
from pathlib import Path
from subprocess import run
Expand Down Expand Up @@ -555,7 +556,22 @@ def get_provider_id(provider_spec: str) -> str:

def get_provider_requirement(provider_spec: str) -> str:
if ">=" in provider_spec:
# we cannot import `airflow` here directly as it would pull re2 and a number of airflow
# dependencies so we need to read airflow version by matching a regexp
airflow_init_content = (AIRFLOW_ROOT_PATH / "airflow" / "__init__.py").read_text()
airflow_version_pattern = r'__version__ = "(\d+\.\d+\.\d+\S*)"'
airflow_version_match = re.search(airflow_version_pattern, airflow_init_content)
if not airflow_version_match:
raise RuntimeError("Cannot find Airflow version in airflow/__init__.py")
from packaging.version import Version

current_airflow_version = Version(airflow_version_match.group(1))
provider_id, min_version = provider_spec.split(">=")
provider_version = Version(min_version)
if provider_version.is_prerelease and not current_airflow_version.is_prerelease:
# strip pre-release version from the pre-installed provider's version when we are preparing
# the official package
min_version = str(provider_version.base_version)
return f"apache-airflow-providers-{provider_id.replace('.', '-')}>={min_version}"
else:
return f"apache-airflow-providers-{provider_spec.replace('.', '-')}"
Expand Down

0 comments on commit 0574e7c

Please sign in to comment.