Commit 9522954
Migrate to pyparsing 3.x and drop Python 2.7 support (#337)
* Migrate from pyparsing 2.x to pyparsing 3.x with PEP8-compliant API
MOTIVATION
----------
Pyparsing 3.0 was released in 2021 and introduced PEP8-compliant naming
conventions for all methods and parameters (camelCase → snake_case). While
backward-compatible aliases were initially provided, pyparsing 3.3.0+ now
emits DeprecationWarnings for old names, and they will be removed in future
versions. This migration future-proofs pyhocon against breaking changes and
aligns the codebase with modern Python conventions.
Additionally, pyparsing 3.x requires Python 3.6.8+, allowing us to drop
Python 2.7 compatibility code and simplify the codebase.
HIGH-LEVEL CHANGES
------------------
1. Updated pyparsing dependency from '>=2,<4' to '>=3.0.0'
2. Dropped Python 2.7, 3.4, 3.5, 3.6 support (now requires Python 3.7+)
3. Updated all pyparsing method calls to PEP8 snake_case names
4. Updated all pyparsing parameter names to PEP8 conventions
5. Removed Python 2.x compatibility shims (basestring, unicode, urllib2, etc.)
6. Added support for Python 3.10, 3.11, 3.12, 3.13
DETAILED CHANGES
----------------
### setup.py
- Changed: 'pyparsing~=2.0;python_version<"3.0"' and 'pyparsing>=2,<4;python_version>="3.0"'
- To: 'pyparsing>=3.0.0' (unified version constraint)
- Removed Python 2.7, 3.4, 3.5, 3.6 from classifiers
- Added Python 3.10, 3.11, 3.12 to classifiers
### tox.ini
- Changed: envlist = flake8, py{27,38,39,310,311,312}
- To: envlist = flake8, py{37,38,39,310,311,312,313}
### pyhocon/config_parser.py
**Import changes:**
- replaceWith → replace_with
**Method name changes (all occurrences):**
- .parseString() → .parse_string()
- .setParseAction() → .set_parse_action()
- .setDefaultWhitespaceChars() → .set_default_whitespace_chars()
**Parameter name changes (all occurrences):**
- caseless=True → case_insensitive=True
- escChar='\' → esc_char='\'
- unquoteResults=False → unquote_results=False
- parseAll=True → parse_all=True
**Python 2.x compatibility removal:**
- Removed try/except blocks for basestring/unicode definitions
- Removed urllib2 fallback imports (now using urllib.request directly)
- Removed Python < 3.5 glob fallback
- Removed Python < 3.4 imp module fallback (now using importlib.util)
- Changed unicode() calls to str()
- Changed isinstance(x, unicode) to isinstance(x, str)
- Updated all docstring type annotations: basestring → str
### pyhocon/period_parser.py
**Method name changes:**
- .parseString() → .parse_string()
- .setParseAction() → .set_parse_action()
**Parameter name changes:**
- parseAll=True → parse_all=True
### pyhocon/config_tree.py
**Python 2.x compatibility removal:**
- Removed try/except block for basestring/unicode
- Changed unicode() calls to str()
- Changed ConfigUnquotedString parent class: unicode → str
- Updated all docstring type annotations: basestring → str
### pyhocon/converter.py
**Python 2.x compatibility removal:**
- Removed try/except block for basestring/unicode
- Changed isinstance(config, basestring) to isinstance(config, str)
- Updated all docstring type annotations: basestring → str
TESTING
-------
All 309 existing tests pass successfully with pyparsing 3.3.1.
No deprecation warnings are emitted when running the test suite.
CLI tool (pyhocon) verified working with new pyparsing version.
BACKWARD COMPATIBILITY
----------------------
This is a BREAKING CHANGE for users:
- Python 2.7 and Python 3.4-3.6 are no longer supported
- Users must upgrade to Python 3.7+ and pyparsing 3.0+
The pyhocon API itself remains unchanged - only internal implementation
and minimum version requirements have changed.
DOCUMENTATION
-------------
Added PYPARSING_MIGRATION_PLAN.md documenting the complete migration
strategy, including all API mappings and testing procedures.
Added CLAUDE.md providing guidance for AI assistants working with this
codebase.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* remove extra documentation
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 50e9c6e commit 9522954
6 files changed
Lines changed: 69 additions & 120 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
85 | 52 | | |
86 | 53 | | |
87 | 54 | | |
| |||
107 | 74 | | |
108 | 75 | | |
109 | 76 | | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
| 77 | + | |
| 78 | + | |
115 | 79 | | |
116 | 80 | | |
117 | 81 | | |
| |||
121 | 85 | | |
122 | 86 | | |
123 | 87 | | |
124 | | - | |
| 88 | + | |
125 | 89 | | |
126 | | - | |
| 90 | + | |
127 | 91 | | |
128 | 92 | | |
129 | 93 | | |
| |||
150 | 114 | | |
151 | 115 | | |
152 | 116 | | |
153 | | - | |
| 117 | + | |
154 | 118 | | |
155 | 119 | | |
156 | 120 | | |
| |||
164 | 128 | | |
165 | 129 | | |
166 | 130 | | |
167 | | - | |
| 131 | + | |
168 | 132 | | |
169 | 133 | | |
170 | 134 | | |
| |||
178 | 142 | | |
179 | 143 | | |
180 | 144 | | |
181 | | - | |
| 145 | + | |
182 | 146 | | |
183 | 147 | | |
184 | 148 | | |
| |||
235 | 199 | | |
236 | 200 | | |
237 | 201 | | |
238 | | - | |
| 202 | + | |
239 | 203 | | |
240 | 204 | | |
241 | 205 | | |
| |||
376 | 340 | | |
377 | 341 | | |
378 | 342 | | |
379 | | - | |
| 343 | + | |
380 | 344 | | |
381 | | - | |
| 345 | + | |
382 | 346 | | |
383 | 347 | | |
384 | 348 | | |
385 | | - | |
386 | | - | |
387 | | - | |
388 | | - | |
389 | | - | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
390 | 354 | | |
391 | 355 | | |
392 | 356 | | |
393 | 357 | | |
394 | 358 | | |
395 | 359 | | |
396 | 360 | | |
397 | | - | |
| 361 | + | |
398 | 362 | | |
399 | 363 | | |
400 | | - | |
| 364 | + | |
401 | 365 | | |
402 | | - | |
| 366 | + | |
403 | 367 | | |
404 | 368 | | |
405 | 369 | | |
406 | 370 | | |
407 | 371 | | |
408 | | - | |
| 372 | + | |
409 | 373 | | |
410 | | - | |
| 374 | + | |
411 | 375 | | |
412 | 376 | | |
413 | 377 | | |
| |||
417 | 381 | | |
418 | 382 | | |
419 | 383 | | |
420 | | - | |
| 384 | + | |
421 | 385 | | |
422 | 386 | | |
423 | 387 | | |
424 | 388 | | |
425 | | - | |
| 389 | + | |
426 | 390 | | |
427 | 391 | | |
428 | 392 | | |
| |||
451 | 415 | | |
452 | 416 | | |
453 | 417 | | |
454 | | - | |
| 418 | + | |
455 | 419 | | |
456 | 420 | | |
457 | 421 | | |
| |||
542 | 506 | | |
543 | 507 | | |
544 | 508 | | |
545 | | - | |
| 509 | + | |
546 | 510 | | |
547 | 511 | | |
548 | 512 | | |
| |||
821 | 785 | | |
822 | 786 | | |
823 | 787 | | |
824 | | - | |
| 788 | + | |
825 | 789 | | |
826 | 790 | | |
827 | 791 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | 7 | | |
14 | 8 | | |
15 | 9 | | |
| |||
219 | 213 | | |
220 | 214 | | |
221 | 215 | | |
222 | | - | |
| 216 | + | |
223 | 217 | | |
224 | 218 | | |
225 | 219 | | |
| |||
228 | 222 | | |
229 | 223 | | |
230 | 224 | | |
231 | | - | |
| 225 | + | |
232 | 226 | | |
233 | 227 | | |
234 | 228 | | |
| |||
239 | 233 | | |
240 | 234 | | |
241 | 235 | | |
242 | | - | |
| 236 | + | |
243 | 237 | | |
244 | | - | |
| 238 | + | |
245 | 239 | | |
246 | | - | |
| 240 | + | |
247 | 241 | | |
248 | 242 | | |
249 | 243 | | |
250 | 244 | | |
251 | 245 | | |
252 | | - | |
| 246 | + | |
253 | 247 | | |
254 | 248 | | |
255 | 249 | | |
| |||
262 | 256 | | |
263 | 257 | | |
264 | 258 | | |
265 | | - | |
| 259 | + | |
266 | 260 | | |
267 | 261 | | |
268 | 262 | | |
| |||
286 | 280 | | |
287 | 281 | | |
288 | 282 | | |
289 | | - | |
| 283 | + | |
290 | 284 | | |
291 | 285 | | |
292 | 286 | | |
| |||
303 | 297 | | |
304 | 298 | | |
305 | 299 | | |
306 | | - | |
| 300 | + | |
307 | 301 | | |
308 | 302 | | |
309 | 303 | | |
| |||
320 | 314 | | |
321 | 315 | | |
322 | 316 | | |
323 | | - | |
| 317 | + | |
324 | 318 | | |
325 | 319 | | |
326 | 320 | | |
| |||
347 | 341 | | |
348 | 342 | | |
349 | 343 | | |
350 | | - | |
| 344 | + | |
351 | 345 | | |
352 | 346 | | |
353 | 347 | | |
| |||
374 | 368 | | |
375 | 369 | | |
376 | 370 | | |
377 | | - | |
| 371 | + | |
378 | 372 | | |
379 | 373 | | |
380 | 374 | | |
| |||
522 | 516 | | |
523 | 517 | | |
524 | 518 | | |
525 | | - | |
| 519 | + | |
526 | 520 | | |
527 | 521 | | |
528 | 522 | | |
| |||
618 | 612 | | |
619 | 613 | | |
620 | 614 | | |
621 | | - | |
| 615 | + | |
622 | 616 | | |
623 | 617 | | |
624 | 618 | | |
| |||
0 commit comments