-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Revised stubs for geoip2 third party library #3317
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
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
0a41f92
Merge pull request #1 from python/master
jolaf 0655e21
Added revised stubs for geoip2 third party library
jolaf 7121a12
Fixed according to flake8
jolaf 9521777
Moving to Python 3 only, as there're compatibility problems with Pyth…
jolaf 13fc3eb
Moved maxminddb and geoip2 stubs to 2and3
jolaf 7ae4387
Fixed for flake8
jolaf 933fe42
Removed extra import
jolaf b46a1af
Copied stdlib ipaddress to thirdparty/2 for Python 2
jolaf d4c05f3
Made stdlib/3/ipaddress.pyi and third_party/2/ipaddress.pyi consistent
jolaf d185521
Removed extra comments
jolaf 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,149 @@ | ||
| from typing import (Any, Container, Generic, Iterable, Iterator, Optional, | ||
| overload, SupportsInt, Text, Tuple, TypeVar) | ||
|
|
||
| # Undocumented length constants | ||
| IPV4LENGTH: int | ||
| IPV6LENGTH: int | ||
|
|
||
| _A = TypeVar("_A", IPv4Address, IPv6Address) | ||
| _N = TypeVar("_N", IPv4Network, IPv6Network) | ||
| _T = TypeVar("_T") | ||
|
|
||
| def ip_address(address: object) -> Any: ... # morally Union[IPv4Address, IPv6Address] | ||
| def ip_network(address: object, strict: bool = ...) -> Any: ... # morally Union[IPv4Network, IPv6Network] | ||
| def ip_interface(address: object) -> Any: ... # morally Union[IPv4Interface, IPv6Interface] | ||
|
|
||
| class _IPAddressBase: | ||
| def __eq__(self, other: Any) -> bool: ... | ||
| def __ge__(self: _T, other: _T) -> bool: ... | ||
| def __gt__(self: _T, other: _T) -> bool: ... | ||
| def __le__(self: _T, other: _T) -> bool: ... | ||
| def __lt__(self: _T, other: _T) -> bool: ... | ||
| def __ne__(self, other: Any) -> bool: ... | ||
| @property | ||
| def compressed(self) -> Text: ... | ||
| @property | ||
| def exploded(self) -> Text: ... | ||
| @property | ||
| def reverse_pointer(self) -> Text: ... | ||
| @property | ||
| def version(self) -> int: ... | ||
|
|
||
| class _BaseAddress(_IPAddressBase, SupportsInt): | ||
| def __init__(self, address: object) -> None: ... | ||
| def __add__(self: _T, other: int) -> _T: ... | ||
| def __hash__(self) -> int: ... | ||
| def __int__(self) -> int: ... | ||
| def __sub__(self: _T, other: int) -> _T: ... | ||
| @property | ||
| def is_global(self) -> bool: ... | ||
| @property | ||
| def is_link_local(self) -> bool: ... | ||
| @property | ||
| def is_loopback(self) -> bool: ... | ||
| @property | ||
| def is_multicast(self) -> bool: ... | ||
| @property | ||
| def is_private(self) -> bool: ... | ||
| @property | ||
| def is_reserved(self) -> bool: ... | ||
| @property | ||
| def is_unspecified(self) -> bool: ... | ||
| @property | ||
| def max_prefixlen(self) -> int: ... | ||
| @property | ||
| def packed(self) -> bytes: ... | ||
|
|
||
| class _BaseNetwork(_IPAddressBase, Container[_A], Iterable[_A], Generic[_A]): | ||
| network_address: _A | ||
| netmask: _A | ||
| def __init__(self, address: object, strict: bool = ...) -> None: ... | ||
| def __contains__(self, other: Any) -> bool: ... | ||
| def __getitem__(self, n: int) -> _A: ... | ||
| def __iter__(self) -> Iterator[_A]: ... | ||
| def address_exclude(self: _T, other: _T) -> Iterator[_T]: ... | ||
| @property | ||
| def broadcast_address(self) -> _A: ... | ||
| def compare_networks(self: _T, other: _T) -> int: ... | ||
| def hosts(self) -> Iterator[_A]: ... | ||
| @property | ||
| def is_global(self) -> bool: ... | ||
| @property | ||
| def is_link_local(self) -> bool: ... | ||
| @property | ||
| def is_loopback(self) -> bool: ... | ||
| @property | ||
| def is_multicast(self) -> bool: ... | ||
| @property | ||
| def is_private(self) -> bool: ... | ||
| @property | ||
| def is_reserved(self) -> bool: ... | ||
| @property | ||
| def is_unspecified(self) -> bool: ... | ||
| @property | ||
| def max_prefixlen(self) -> int: ... | ||
| @property | ||
| def num_addresses(self) -> int: ... | ||
| def overlaps(self: _T, other: _T) -> bool: ... | ||
| @property | ||
| def prefixlen(self) -> int: ... | ||
| def subnets(self: _T, prefixlen_diff: int = ..., new_prefix: Optional[int] = ...) -> Iterator[_T]: ... | ||
| def supernet(self: _T, prefixlen_diff: int = ..., new_prefix: Optional[int] = ...) -> _T: ... | ||
| @property | ||
| def with_hostmask(self) -> Text: ... | ||
| @property | ||
| def with_netmask(self) -> Text: ... | ||
| @property | ||
| def with_prefixlen(self) -> Text: ... | ||
| @property | ||
| def hostmask(self) -> _A: ... | ||
|
|
||
| class _BaseInterface(_BaseAddress, Generic[_A, _N]): | ||
| hostmask: _A | ||
| netmask: _A | ||
| network: _N | ||
| @property | ||
| def ip(self) -> _A: ... | ||
| @property | ||
| def with_hostmask(self) -> Text: ... | ||
| @property | ||
| def with_netmask(self) -> Text: ... | ||
| @property | ||
| def with_prefixlen(self) -> Text: ... | ||
|
|
||
| class IPv4Address(_BaseAddress): ... | ||
| class IPv4Network(_BaseNetwork[IPv4Address]): ... | ||
| class IPv4Interface(IPv4Address, _BaseInterface[IPv4Address, IPv4Network]): ... | ||
|
|
||
| class IPv6Address(_BaseAddress): | ||
| @property | ||
| def ipv4_mapped(self) -> Optional[IPv4Address]: ... | ||
| @property | ||
| def is_site_local(self) -> bool: ... | ||
| @property | ||
| def sixtofour(self) -> Optional[IPv4Address]: ... | ||
| @property | ||
| def teredo(self) -> Optional[Tuple[IPv4Address, IPv4Address]]: ... | ||
|
|
||
| class IPv6Network(_BaseNetwork[IPv6Address]): | ||
| @property | ||
| def is_site_local(self) -> bool: ... | ||
|
|
||
| class IPv6Interface(IPv6Address, _BaseInterface[IPv6Address, IPv6Network]): ... | ||
|
|
||
| def v4_int_to_packed(address: int) -> bytes: ... | ||
| def v6_int_to_packed(address: int) -> bytes: ... | ||
| @overload | ||
| def summarize_address_range(first: IPv4Address, last: IPv4Address) -> Iterator[IPv4Network]: ... | ||
| @overload | ||
| def summarize_address_range(first: IPv6Address, last: IPv6Address) -> Iterator[IPv6Network]: ... | ||
| def collapse_addresses(addresses: Iterable[_N]) -> Iterator[_N]: ... | ||
| @overload | ||
| def get_mixed_type_key(obj: _A) -> Tuple[int, _A]: ... | ||
| @overload | ||
| def get_mixed_type_key(obj: IPv4Network) -> Tuple[int, IPv4Address, IPv4Address]: ... | ||
| @overload | ||
| def get_mixed_type_key(obj: IPv6Network) -> Tuple[int, IPv6Address, IPv6Address]: ... | ||
|
|
||
| class AddressValueError(ValueError): ... | ||
| class NetmaskValueError(ValueError): ... | ||
Empty file.
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 |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| from types import TracebackType | ||
| from typing import Optional, Sequence, Text, Type | ||
|
|
||
| from maxminddb.reader import Metadata | ||
| from geoip2.models import AnonymousIP, ASN, City, ConnectionType, Country, Domain, Enterprise, ISP | ||
|
|
||
| _Locales = Optional[Sequence[Text]] | ||
|
|
||
| class Reader: | ||
| def __init__(self, filename: Text, locales: _Locales = ..., mode: int = ...) -> None: ... | ||
| def __enter__(self) -> Reader: ... | ||
| def __exit__(self, exc_type: Optional[Type[BaseException]] = ..., exc_val: Optional[BaseException] = ..., exc_tb: Optional[TracebackType] = ...) -> None: ... | ||
| def country(self, ip_address: Text) -> Country: ... | ||
| def city(self, ip_address: Text) -> City: ... | ||
| def anonymous_ip(self, ip_address: Text) -> AnonymousIP: ... | ||
| def asn(self, ip_address: Text) -> ASN: ... | ||
| def connection_type(self, ip_address: Text) -> ConnectionType: ... | ||
| def domain(self, ip_address: Text) -> Domain: ... | ||
| def enterprise(self, ip_address: Text) -> Enterprise: ... | ||
| def isp(self, ip_address: Text) -> ISP: ... | ||
| def metadata(self) -> Metadata: ... | ||
| def close(self) -> None: ... |
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 |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| from typing import Optional, Text | ||
|
|
||
| class GeoIP2Error(RuntimeError): ... | ||
|
|
||
| class AddressNotFoundError(GeoIP2Error): ... | ||
|
|
||
| class AuthenticationError(GeoIP2Error): ... | ||
|
|
||
| class HTTPError(GeoIP2Error): | ||
| http_status: Optional[int] | ||
| uri: Optional[Text] | ||
| def __init__(self, message: Text, http_status: Optional[int] = ..., uri: Optional[Text] = ...) -> None: ... | ||
|
|
||
| class InvalidRequestError(GeoIP2Error): ... | ||
|
|
||
| class OutOfQueriesError(GeoIP2Error): ... | ||
|
|
||
| class PermissionRequiredError(GeoIP2Error): ... |
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 |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| class SimpleEquality: | ||
| def __eq__(self, other: object) -> bool: ... | ||
| def __ne__(self, other: object) -> bool: ... |
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 |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| from typing import Any, Mapping, Optional, Sequence, Text | ||
|
|
||
| from geoip2 import records | ||
|
|
||
| from geoip2.mixins import SimpleEquality | ||
|
|
||
| _Locales = Optional[Sequence[Text]] | ||
| _RawResponse = Mapping[Text, Mapping[Text, Any]] | ||
|
|
||
| class Country(SimpleEquality): | ||
| continent: records.Continent | ||
| country: records.Country | ||
| registered_country: records.Country | ||
| represented_country: records.RepresentedCountry | ||
| maxmind: records.MaxMind | ||
| traits: records.Traits | ||
| raw: _RawResponse | ||
| def __init__(self, raw_response: _RawResponse, locales: _Locales = ...) -> None: ... | ||
|
|
||
| class City(Country): | ||
| city: records.City | ||
| location: records.Location | ||
| postal: records.Postal | ||
| subdivisions: records.Subdivisions | ||
| def __init__(self, raw_response: _RawResponse, locales: _Locales = ...) -> None: ... | ||
|
|
||
| class Insights(City): ... | ||
|
|
||
| class Enterprise(City): ... | ||
|
|
||
| class SimpleModel(SimpleEquality): ... | ||
|
|
||
| class AnonymousIP(SimpleModel): | ||
| is_anonymous: bool | ||
| is_anonymous_vpn: bool | ||
| is_hosting_provider: bool | ||
| is_public_proxy: bool | ||
| is_tor_exit_node: bool | ||
| ip_address: Optional[Text] | ||
| raw: _RawResponse | ||
| def __init__(self, raw: _RawResponse) -> None: ... | ||
|
|
||
| class ASN(SimpleModel): | ||
| autonomous_system_number: Optional[int] | ||
| autonomous_system_organization: Optional[Text] | ||
| ip_address: Optional[Text] | ||
| raw: _RawResponse | ||
| def __init__(self, raw: _RawResponse) -> None: ... | ||
|
|
||
| class ConnectionType(SimpleModel): | ||
| connection_type: Optional[Text] | ||
| ip_address: Optional[Text] | ||
| raw: _RawResponse | ||
| def __init__(self, raw: _RawResponse) -> None: ... | ||
|
|
||
| class Domain(SimpleModel): | ||
| domain: Optional[Text] | ||
| ip_address: Optional[Text] | ||
| raw: Optional[Text] | ||
| def __init__(self, raw: _RawResponse) -> None: ... | ||
|
|
||
| class ISP(ASN): | ||
| isp: Optional[Text] | ||
| organization: Optional[Text] | ||
| def __init__(self, raw: _RawResponse) -> None: ... |
Oops, something went wrong.
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.