8000 Deprecate `geocode`-specific args in `__init__` by KostyaEsmukov · Pull Request #350 · geopy/geopy · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Deprecate geocode-specific args in __init__ #350

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 1 commit into from
Mar 23, 2019

Conversation

KostyaEsmukov
Copy link
Member

__init__ args which are specific to the geocode methods have been deprecated in this PR.

The motivation is:

  1. They raise questions like "do they affect other methods like reverse?"
  2. They tend to not have a corresponding param in the geocode method, which forces to create new instances of geocoder for queries which need different values for such args.
  3. Most of the geocode args still cannot be specified in the __init__ methods.
  4. They clutter the __init__ method args which naturally should specify only the credentials and connectivity settings (well, except for the format_string).

As an alternative I'd suggest to use functools.partial:

# Change this:
#   geocoder = GeocodeEarth("my_api_key", country_bias="US")
#   location = geocoder.geocode("new york")
# to this:

from functools import partial

geocoder = GeocodeEarth("my_api_key")
geocode = partial(geocoder.geocode, country_bias="US")
location = geocode("new york")

@KostyaEsmukov KostyaEsmukov added this to the 1.19 milestone Mar 23, 2019
@KostyaEsmukov KostyaEsmukov merged commit 9bde5b2 into master Mar 23, 2019
@KostyaEsmukov KostyaEsmukov deleted the deprecate-args-of-geocode-in-init branch March 23, 2019 21:42
@KostyaEsmukov
Copy link
Member Author

Also related (Yandex geocoder): 2907bff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0