diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..00c2dfb --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,10 @@ +version: 2 +updates: + - package-ecosystem: pip + directory: / + schedule: + interval: weekly + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 49fba71..42349be 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -2,31 +2,21 @@ name: Codecov workflow on: [pull_request] jobs: run: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest] - env: - OS: ${{ matrix.os }} - PYTHON: '3.7' + runs-on: ubuntu-latest steps: - - uses: actions/checkout@main + - uses: actions/checkout@v4 - name: Setup Python - uses: actions/setup-python@main + uses: actions/setup-python@v5 with: - python-version: 3.7 + python-version: '3.12' - name: Generate coverage report run: | - pip install Faker pytest pytest-cov pytest-socket requests requests_mock validators + pip install -r requirements.txt -r requirements-dev.txt pytest --cov=./ --cov-report=xml - name: Upload coverage to Codecov - uses: codecov/codecov-action@v2 + uses: codecov/codecov-action@v5 with: - directory: ./coverage/reports/ - env_vars: OS,PYTHON - fail_ci_if_error: true + token: ${{ secrets.CODECOV_TOKEN }} files: ./coverage.xml flags: unittests - name: codecov-umbrella - path_to_write_report: ./coverage/codecov_report.txt - verbose: true + fail_ci_if_error: false diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml index 6da85fc..450b4f8 100644 --- a/.github/workflows/linters.yml +++ b/.github/workflows/linters.yml @@ -7,18 +7,17 @@ jobs: strategy: fail-fast: false matrix: - python-version: [3.7.9] + python-version: ["3.12"] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install flake8 - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + pip install -r requirements.txt -r requirements-dev.txt - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ff5afdc..6d31ae3 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -8,17 +8,17 @@ jobs: strategy: fail-fast: false matrix: - python-version: [3.7.9] + python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install Faker pytest pytest-socket requests requests_mock validators + pip install -r requirements.txt -r requirements-dev.txt - name: Test with pytest run: | pytest diff --git a/README.md b/README.md index c53bc3a..c22bb00 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ See the Urlbox API Docs. ## Requirements -Python 3.x +Python 3.10+ ## Installation diff --git a/pyproject.toml b/pyproject.toml index b5a3c46..a9cea2c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,30 @@ [build-system] -requires = [ - "setuptools>=42", - "wheel" +requires = ["setuptools>=61"] +build-backend = "setuptools.build_meta" + +[project] +name = "urlbox" +version = "1.0.7" +description = "Official Python client for the Urlbox API" +readme = "README.md" +license = { text = "MIT" } +authors = [{ name = "Urlbox", email = "support@urlbox.com" }] +requires-python = ">=3.10" +dependencies = ["requests>=2.33.0,<3", "validators>=0.18.2"] +classifiers = [ + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", ] -build-backend = "setuptools.build_meta" \ No newline at end of file + +[project.urls] +Homepage = "https://github.com/urlbox/urlbox-python" +"Bug Tracker" = "https://github.com/urlbox/urlbox-python/issues" + +[tool.setuptools.packages.find] +include = ["urlbox*"] diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..9fe8d56 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,6 @@ +Faker +flake8 +pytest +pytest-cov +pytest-socket +requests-mock diff --git a/requirements.txt b/requirements.txt index d33fb16..d361c43 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -requests==2.26.0 -validators==0.18.2 +requests>=2.33.0,<3 +validators>=0.18.2 diff --git a/setup.py b/setup.py deleted file mode 100644 index ad86fbb..0000000 --- a/setup.py +++ /dev/null @@ -1,27 +0,0 @@ -import setuptools - -with open("README.md", "r", encoding="utf-8") as fh: - long_description = fh.read() - -setuptools.setup( - name="urlbox", - version="1.0.6", - author="Urlbox", - author_email="support@urlbox.io", - description="Official Python client for the Ulrbox API", - license="MIT", - long_description=long_description, - long_description_content_type="text/markdown", - url="https://github.com/urlbox/urlbox-python", - project_urls={ - "Bug Tracker": "https://github.com/urlbox/urlbox-python/issues" - }, - classifiers=[ - "Programming Language :: Python :: 3", - "License :: OSI Approved :: MIT License", - "Operating System :: OS Independent", - ], - packages=setuptools.find_packages(), - python_requires=">=3.7", - install_requires=["requests==2.26.0", "validators==0.18.2"], -) diff --git a/tests/test_urlbox_client.py b/tests/test_urlbox_client.py index 3f6c7bd..f5d6909 100644 --- a/tests/test_urlbox_client.py +++ b/tests/test_urlbox_client.py @@ -36,9 +36,8 @@ def test_api_key_not_provided(): with pytest.raises(TypeError) as type_error: UrlboxClient() - assert ( - str(type_error.value) - == "__init__() missing 1 required keyword-only argument: 'api_key'" + assert str(type_error.value).endswith( + "__init__() missing 1 required keyword-only argument: 'api_key'" ) diff --git a/urlbox/webhook_validator.py b/urlbox/webhook_validator.py index 4b6fe28..bb5b411 100644 --- a/urlbox/webhook_validator.py +++ b/urlbox/webhook_validator.py @@ -64,9 +64,11 @@ def _check_timestamp(timestamp): def _check_webhook_creation_time(timestamp): - header_datetime = datetime.datetime.utcfromtimestamp(timestamp) + header_datetime = datetime.datetime.fromtimestamp( + timestamp, datetime.timezone.utc + ) - current_datetime = datetime.datetime.utcnow() + current_datetime = datetime.datetime.now(datetime.timezone.utc) webhook_posted = current_datetime - header_datetime webhook_posted_minutes_ago = webhook_posted.total_seconds() / 60