Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/links.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Links

on:
push:
pull_request:
schedule:
- cron: "0 13 * * 1" # weekly, to catch external link rot without a commit
workflow_dispatch:

permissions:
contents: read

jobs:
linkChecker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false

- name: Setup mise
uses: jdx/mise-action@6d1e696aa24c1aa1bcc1adea0212707c71ab78a8 # v3.6.1
with:
install: false

# Install only lychee (not the repo's full toolchain) and run the check.
- name: Check links
env:
MISE_AUTO_INSTALL: "false"
run: |
mise install lychee
mise run check-links
7 changes: 5 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ jobs:
persist-credentials: false

- name: Install the latest version of uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # 8.1.0
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
with:
# Disable caching in the release workflow (zizmor cache-poisoning).
enable-cache: false

- name: Build
run: uv build
Expand All @@ -47,4 +50,4 @@ jobs:
name: artifact
path: dist

- uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # 1.14.0
- uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
submodules: true
persist-credentials: false
- name: Install the latest version of uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # 8.1.0
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
- name: Install tox
run: uv tool install --python-preference only-managed --python 3.13 tox --with tox-uv --with tox-gh
- name: Install Python
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ MANIFEST
*.swp
.tox
/venv
.lycheecache
4 changes: 2 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ uv run tox

## Additional Resources

- [API Documentation](https://geoip2.readthedocs.org/)
- [GeoIP Web Services Docs](https://dev.maxmind.com/geoip/docs/web-services)
- [API Documentation](https://geoip2.readthedocs.io/en/latest/)
- [GeoIP Web Services Docs](https://dev.maxmind.com/geoip/docs/web-services/)
- [MaxMind DB Format](https://maxmind.github.io/MaxMind-DB/)
- GitHub Issues: https://github.com/maxmind/GeoIP2-python/issues
13 changes: 7 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Description
-----------

This package provides an API for the GeoIP and GeoLite `web services
<https://dev.maxmind.com/geoip/docs/web-services?lang=en>`_ and `databases
<https://dev.maxmind.com/geoip/docs/databases?lang=en>`_.
<https://dev.maxmind.com/geoip/docs/web-services/?lang=en>`_ and `databases
<https://dev.maxmind.com/geoip/docs/databases/?lang=en>`_.

Installation
------------
Expand Down Expand Up @@ -164,7 +164,7 @@ Web Service Client Exceptions
-----------------------------

For details on the possible errors returned by the web service itself, see
https://dev.maxmind.com/geoip/docs/web-services?lang=en for the GeoIP web
https://dev.maxmind.com/geoip/docs/web-services/?lang=en for the GeoIP web
service docs.

If the web service returns an explicit error document, this is thrown as a
Expand Down Expand Up @@ -515,7 +515,8 @@ Reporting Data Problems
-----------------------

If the problem you find is that an IP address is incorrectly mapped, please
`submit your correction to MaxMind <https://www.maxmind.com/en/correction>`_.
`submit your correction to MaxMind
<https://www.maxmind.com/en/geoip-data-correction-request>`_.

If you find some other sort of mistake, like an incorrect spelling, please
check the `GeoNames site <https://www.geonames.org/>`_ first. Once you've
Expand All @@ -526,7 +527,7 @@ will be automatically incorporated into future MaxMind releases.

If you are a paying MaxMind customer and you're not sure where to submit a
correction, please `contact MaxMind support
<https://www.maxmind.com/en/support>`_ for help.
<https://support.maxmind.com/knowledge-base>`_ for help.

Versioning
----------
Expand All @@ -541,4 +542,4 @@ Please report all issues with this code using the `GitHub issue tracker

If you are having an issue with a MaxMind service that is not specific to the
client API, please contact `MaxMind support
<https://www.maxmind.com/en/support>`_ for assistance.
<https://support.maxmind.com/knowledge-base>`_ for assistance.
64 changes: 64 additions & 0 deletions lychee.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Lychee link checker configuration
# https://lychee.cli.rs/#/usage/config
#
# Run locally with:
# lychee './**/*.md' './**/*.rst' './src/**/*.py' './pyproject.toml'

# Include URL fragments in checks
include_fragments = true

# Don't allow any redirects, so links that have moved are surfaced and can be
# updated to their canonical destination.
max_redirects = 0
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using max_redirects = 0 will cause any redirect (including standard HTTP to HTTPS upgrades or minor path adjustments on external sites) to fail the CI build. While this is useful for identifying links to update to their canonical forms, enforcing it strictly in a blocking CI workflow can lead to flaky builds when external websites change their redirect behavior. Consider allowing a small number of redirects (e.g., max_redirects = 5) to prevent unrelated PRs from being blocked by external changes.

Suggested change
max_redirects = 0
max_redirects = 5

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intentionally keeping max_redirects = 0. Surfacing moved/redirecting links is the goal of this change (STF-557), and it matches the dev-site and blog-site lychee configs; redirects are resolved by updating the link to its canonical target.

— Claude (posted on Greg's behalf)


# Accept these HTTP status codes
# 100-103: Informational responses
# 200-299: Success responses
# 403: Forbidden (some sites use this for rate limiting)
# 429: Too Many Requests
# 500-599: Server errors (temporary issues shouldn't fail CI)
# 999: LinkedIn's custom status code
accept = ["100..=103", "200..=299", "403", "429", "500..=599", "999"]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Including "500..=599" in the accept list means that any link returning a server-side error (such as 500 Internal Server Error, 502 Bad Gateway, or 503 Service Unavailable) will be treated as a success. While this prevents transient server issues from failing the build, it also silences permanently broken links that fail with server errors. It is generally safer to remove 500..=599 from the accepted list and rely on Lychee's built-in retry mechanism or CI-level retries to handle temporary server issues.

Suggested change
accept = ["100..=103", "200..=299", "403", "429", "500..=599", "999"]
accept = ["100..=103", "200..=299", "403", "429", "999"]

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping 500..=599 in accept, matching the dev-site and blog-site configs — transient upstream 5xx shouldn't fail link-checking CI.

— Claude (posted on Greg's behalf)


# Exclude URL patterns from checking (treated as regular expressions)
exclude = [
# GitHub blob URLs with line-number fragments (not parseable as page anchors)
'^https://github\.com/[^/]+/[^/]+/blob/[0-9a-fA-F]+/.+#L\d+$',
# Live / auth-gated MaxMind endpoints: appear as code string literals or
# require login, so they can't be verified by an anonymous request.
'^https://geoip\.maxmind\.com',
'^https://geolite\.info',
'^https://minfraud\.maxmind\.com',
'^https://sandbox\.maxmind\.com',
'^https://updates\.maxmind\.com',
'^https://www\.maxmind\.com/en/accounts/',
'^https://www\.maxmind\.com/en/account/login',
# Local / placeholder URLs (e.g. the proxy example in docstrings)
'^file://',
'^https?://example\.(com|org|net)',
'^http://localhost',
'127\.0\.0\.1',
]

# Exclude file paths from getting checked (regular expressions, matched against
# the path relative to the working directory). Patterns are segment-anchored
# with (^|/) so short names like "build" don't match unintended paths.
exclude_path = [
'(^|/)node_modules/',
'(^|/)\.venv/',
'(^|/)venv/',
'(^|/)build/',
'(^|/)dist/',
'(^|/)\.eggs/',
'(^|/)[^/]*\.egg-info/',
'(^|/)docs/_build/',
# Changelog: historical entries are preserved as-is, not rewritten
'(^|/)HISTORY\.rst$',
]

# Cache results for 1 day to speed up repeated checks
cache = true
max_cache_age = "1d"

# Skip missing input files instead of erroring
skip_missing = true
28 changes: 28 additions & 0 deletions mise.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
# @generated - this file is auto-generated by `mise lock` https://mise.jdx.dev/dev-tools/mise-lock.html

[[tools.lychee]]
version = "0.23.0"
backend = "aqua:lycheeverse/lychee"

[tools.lychee."platforms.linux-arm64"]
checksum = "sha256:97eb93b02a7d78a752fc33e5b0983439ccaadbf3db952b68a0a4401acd92e6e0"
url = "https://github.com/lycheeverse/lychee/releases/download/lychee-v0.23.0/lychee-aarch64-unknown-linux-gnu.tar.gz"

[tools.lychee."platforms.linux-arm64-musl"]
checksum = "sha256:97eb93b02a7d78a752fc33e5b0983439ccaadbf3db952b68a0a4401acd92e6e0"
url = "https://github.com/lycheeverse/lychee/releases/download/lychee-v0.23.0/lychee-aarch64-unknown-linux-gnu.tar.gz"

[tools.lychee."platforms.linux-x64"]
checksum = "sha256:5538440d2c69a45a0a09983271e5dee0c2fe7137d8035d25b2632e10a66a090a"
url = "https://github.com/lycheeverse/lychee/releases/download/lychee-v0.23.0/lychee-x86_64-unknown-linux-musl.tar.gz"

[tools.lychee."platforms.linux-x64-musl"]
checksum = "sha256:5538440d2c69a45a0a09983271e5dee0c2fe7137d8035d25b2632e10a66a090a"
url = "https://github.com/lycheeverse/lychee/releases/download/lychee-v0.23.0/lychee-x86_64-unknown-linux-musl.tar.gz"

[tools.lychee."platforms.macos-arm64"]
checksum = "sha256:4c8034900e11083b68ac6f6582c377ff1f704e268991999e09d717973e493e7f"
url = "https://github.com/lycheeverse/lychee/releases/download/lychee-v0.23.0/lychee-arm64-macos.dmg"

[tools.lychee."platforms.windows-x64"]
checksum = "sha256:0fda7ff0a60c0250939fc25361c2d4e6e7853c31c996733fdd5a1dd760bcb824"
url = "https://github.com/lycheeverse/lychee/releases/download/lychee-v0.23.0/lychee-x86_64-windows.exe"

[[tools.python]]
version = "3.13.11"
backend = "core:python"
Expand Down
5 changes: 5 additions & 0 deletions mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@ disable_backends = [
[tools]
python = "latest"
uv = "latest"
lychee = "latest"

[hooks]
enter = "mise install --quiet --locked"

[[watch_files]]
patterns = ["mise.toml", "mise.lock"]
run = "mise install --quiet --locked"

[tasks.check-links]
description = "Check links with lychee"
run = "lychee --no-progress './**/*.md' './**/*.rst' './src/**/*.py' './pyproject.toml'"
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ source-include = [
]

[project.urls]
Homepage = "https://www.maxmind.com/"
Documentation = "https://geoip2.readthedocs.org/"
Homepage = "https://www.maxmind.com/en/home"
Documentation = "https://geoip2.readthedocs.io/en/latest/"
"Source Code" = "https://github.com/maxmind/GeoIP2-python"
"Issue Tracker" = "https://github.com/maxmind/GeoIP2-python/issues"

Expand Down
2 changes: 1 addition & 1 deletion src/geoip2/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
The only difference between the City and Insights model classes is which
fields in each record may be populated. See
https://dev.maxmind.com/geoip/docs/web-services?lang=en for more details.
https://dev.maxmind.com/geoip/docs/web-services/?lang=en for more details.
"""

from __future__ import annotations
Expand Down
2 changes: 1 addition & 1 deletion src/geoip2/records.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ class Traits(Record):
.. deprecated:: 2.2.0
Use our `GeoIP Anonymous IP database
<https://www.maxmind.com/en/geoip2-anonymous-ip-database>`_
<https://www.maxmind.com/en/geoip-anonymous-ip-database>`_
instead.
"""
is_anonymous_vpn: bool
Expand Down
8 changes: 4 additions & 4 deletions src/geoip2/webservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ class AsyncClient(BaseClient):
:param account_id: Your MaxMind account ID.
:param license_key: Your MaxMind license key.
Go to https://www.maxmind.com/en/my_license_key to see your MaxMind
account ID and license key.
Go to https://www.maxmind.com/en/accounts/current/license-key to see
your MaxMind account ID and license key.
The following keyword arguments are also accepted:
Expand Down Expand Up @@ -412,8 +412,8 @@ class Client(BaseClient):
:param account_id: Your MaxMind account ID.
:param license_key: Your MaxMind license key.
Go to https://www.maxmind.com/en/my_license_key to see your MaxMind
account ID and license key.
Go to https://www.maxmind.com/en/accounts/current/license-key to see
your MaxMind account ID and license key.
The following keyword arguments are also accepted:
Expand Down
Loading