Skip to content

Commit 47fdeec

Browse files
oschwaldclaude
andcommitted
Fix syntax errors and improve idiomatic style in code samples
- PHP: Add missing semicolons after require_once, use $camelCase variables - Python: Remove trailing semicolons, fix missing imports and closing quotes - C#/Java: Change # comments to // (correct syntax) - JavaScript/Ruby: Add missing commas in objects/hashes - Python async examples: Fix to use AsyncClient with async with/await 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 5b5bf1d commit 47fdeec

File tree

4 files changed

+160
-153
lines changed

4 files changed

+160
-153
lines changed

content/geoip/geolocate-an-ip/databases.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ const dbBuffer = fs.readFileSync('/path/to/maxmind-database.mmdb');
136136
// expensive.
137137
const reader = Reader.openBuffer(dbBuffer);
138138

139-
response = reader.city('128.101.101.101');
139+
const response = reader.city('128.101.101.101');
140140

141141
console.log(response.country.isoCode);
142142
```
@@ -161,7 +161,7 @@ import geoip2.database
161161
# This reader object should be reused across lookups as creation of it is
162162
# expensive.
163163
with geoip2.database.Reader('/path/to/maxmind-database.mmdb') as reader:
164-
response = reader.city('128.101.101.101');
164+
response = reader.city('128.101.101.101')
165165
print(response.country.iso_code)
166166
```
167167

content/geoip/geolocate-an-ip/web-services.md

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -122,23 +122,23 @@ const client = new WebServiceClient(accountId, licenseKey, {
122122
```
123123

124124
```php
125-
<?php require_once 'vendor/autoload.php'
125+
<?php
126+
require_once 'vendor/autoload.php';
126127
use GeoIp2\WebService\Client;
127128

128-
$account_id = 10;
129-
$license_key = 'LICENSEKEY';
129+
$accountId = 10;
130+
$licenseKey = 'LICENSEKEY';
130131

131-
$client = new Client($account_id, $license_key);
132+
$client = new Client($accountId, $licenseKey);
132133

133134
// To query the GeoLite web service, you must set the optional `host` argument.
134135
// The third argument specifies the language preferences when using the `->name`
135136
// method on the model classes that this client creates.
136-
$client = new Client($account_id, $license_key, ['en'], ['host' => 'geolite.info']);
137+
$client = new Client($accountId, $licenseKey, ['en'], ['host' => 'geolite.info']);
137138
```
138139

139140
```python
140-
import asyncio # for async requests with AsyncClient
141-
import geoip2.webservice
141+
from geoip2.webservice import Client, AsyncClient
142142

143143
account_id = 10
144144
license_key = 'LICENSEKEY'
@@ -150,7 +150,7 @@ client = Client(account_id, license_key)
150150
# to "geolite.info"
151151
client = Client(account_id, license_key, host='geolite.info')
152152

153-
# Or if you want to use asynchronous requests
153+
# Or if you want to use asynchronous requests (requires `import asyncio`)
154154
async_client = AsyncClient(account_id, license_key)
155155

156156
# To query the GeoLite web service, you must set the "host" keyword argument
@@ -247,13 +247,14 @@ client.country('142.1.1.1').then((response) => {
247247
```
248248

249249
```php
250-
<?php require_once 'vendor/autoload.php'
250+
<?php
251+
require_once 'vendor/autoload.php';
251252
use GeoIp2\WebService\Client;
252253

253-
$account_id = 10;
254-
$license_key = 'LICENSEKEY';
254+
$accountId = 10;
255+
$licenseKey = 'LICENSEKEY';
255256

256-
$client = new Client($account_id, $license_key);
257+
$client = new Client($accountId, $licenseKey);
257258

258259
// You can also use `$client->city` or `$client->insights`
259260
// `$client->insights` is not available to GeoLite users
@@ -264,27 +265,27 @@ print($record->country->isoCode . "\n");
264265

265266
```python
266267
# Sync
267-
import geoip2.webservice
268+
from geoip2.webservice import Client
268269

269270
account_id = 10
270271
license_key = 'LICENSEKEY'
271272

272-
with geoip2.webservice.Client(account_id, license_key) as client:
273+
with Client(account_id, license_key) as client:
273274
# You can also use `client.city` or `client.insights`
274275
# `client.insights` is not available to GeoLite users
275-
response = client.country('128.101.101.101)
276+
response = client.country('128.101.101.101')
276277

277278
print(response.country.iso_code)
278279

279280
# Async
280281
import asyncio
281-
import geoip2.webservice
282+
from geoip2.webservice import AsyncClient
282283

283284
async def main():
284-
async with geoip2.webservice.AsyncClient(account_id, license_key) as client:
285+
async with AsyncClient(account_id, license_key) as client:
285286
# You can also use `client.city` or `client.insights`
286287
# `client.insights` is not available to GeoLite users
287-
response = await client.country('128.101.101.101)
288+
response = await client.country('128.101.101.101')
288289

289290
print(response.country.iso_code)
290291

0 commit comments

Comments
 (0)