-
Notifications
You must be signed in to change notification settings - Fork 42
Switch to ruff #204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Switch to ruff #204
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
c4f2117
Switch to ruff for formatting
oschwald c4f2d1f
Run ruff fix
oschwald c71f4e6
Run ruff unsafe fixes
oschwald 5627ef8
Add __init__.py file
oschwald f441cfd
Improve typing
oschwald 9a524be
Improve docs
oschwald 0993389
Minor style fixes and ignoring of particular lints
oschwald 6c3f2e2
Switch to ruff for linting
oschwald ffc1fd3
Remove pylint/flake8 specific settings
oschwald 47b0ebc
Install libasan6 to fix Address Sanitizer build
oschwald 06fd36f
Update asan test to use uv
oschwald 1027fb4
Use astral-sh/setup-uv for other builds
oschwald a27c517
Fix indentation and remove generic comments
oschwald 63fc04d
Consistently import annotations from future
oschwald ccce395
Print out the benchmark results again
oschwald efd955f
Add back docs to type stub file
oschwald 2cfb293
Delete pylint directive
oschwald File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,65 +1,47 @@ | ||
| """C extension database reader and related classes.""" | ||
horgh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| # pylint: disable=E0601,E0602 | ||
| from ipaddress import IPv4Address, IPv6Address | ||
| from os import PathLike | ||
| from typing import IO, Any, AnyStr, Optional, Union | ||
| from typing import IO, Any, AnyStr | ||
|
|
||
| from typing_extensions import Self | ||
|
|
||
| from maxminddb.types import Record | ||
|
|
||
| class Reader: | ||
| """A C extension implementation of a reader for the MaxMind DB format. IP | ||
| addresses can be looked up using the ``get`` method. | ||
| """ | ||
|
|
||
|
|
||
| closed: bool = ... | ||
|
|
||
| def __init__( | ||
| self, | ||
| database: Union[AnyStr, int, PathLike, IO], | ||
| database: AnyStr | int | PathLike | IO, | ||
| mode: int = ..., | ||
| ) -> None: | ||
| """Reader for the MaxMind DB file format | ||
|
|
||
| Arguments: | ||
| database -- A path to a valid MaxMind DB file such as a GeoIP2 database | ||
| file, or a file descriptor in the case of MODE_FD. | ||
| mode -- mode to open the database with. The only supported modes are | ||
| MODE_AUTO and MODE_MMAP_EXT. | ||
|
|
||
| """ | ||
| ... | ||
|
|
||
| def close(self) -> None: | ||
| """Closes the MaxMind DB file and returns the resources to the system""" | ||
| ... | ||
|
|
||
| def get(self, ip_address: Union[str, IPv6Address, IPv4Address]) -> Optional[Record]: | ||
| """Return the record for the ip_address in the MaxMind DB | ||
|
|
||
| Arguments: | ||
| ip_address -- an IP address in the standard string notation | ||
|
|
||
| """ | ||
| def get(self, ip_address: str | IPv6Address | IPv4Address) -> Record | None: | ||
| ... | ||
|
|
||
| def get_with_prefix_len( | ||
| self, | ||
| ip_address: Union[str, IPv6Address, IPv4Address], | ||
| ) -> tuple[Optional[Record], int]: | ||
| """Return a tuple with the record and the associated prefix length | ||
|
|
||
| Arguments: | ||
| ip_address -- an IP address in the standard string notation | ||
|
|
||
| """ | ||
| ip_address: str | IPv6Address | IPv4Address, | ||
| ) -> tuple[Record | None, int]: | ||
| ... | ||
|
|
||
| def metadata(self) -> Metadata: | ||
| """Return the metadata associated with the MaxMind DB file""" | ||
| ... | ||
|
|
||
| def __enter__(self) -> Reader: ... | ||
| def __enter__(self) -> Self: ... | ||
| def __exit__(self, *args) -> None: ... | ||
|
|
||
| # pylint: disable=too-few-public-methods | ||
|
||
| class Metadata: | ||
| """Metadata for the MaxMind DB reader""" | ||
|
|
||
|
|
||
| binary_format_major_version: int | ||
| """ | ||
|
|
@@ -111,4 +93,4 @@ class Metadata: | |
| """ | ||
|
|
||
| def __init__(self, **kwargs: Any) -> None: | ||
| """Creates new Metadata object. kwargs are key/value pairs from spec""" | ||
| ... | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.