Skip to content

DEV: Remove unused reverse encoding dicts - #3685

Merged
stefan6419846 merged 2 commits into
py-pdf:mainfrom
duriantaco:remove-dead-code
Mar 16, 2026
Merged

stefan6419846 merged 2 commits into
py-pdf:mainfrom
duriantaco:remove-dead-code

Conversation

@duriantaco

@duriantaco duriantaco commented Mar 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Removed 5 unused symbols identified via static analysis using Skylos (zero references across entire codebase)
  • 2 files changed, 12 deletions, 0 additions

Changes

Symbol File Reason
FieldFlag pypdf/constants.py IntFlag class (Table 8.70) never used or imported anywhere
_win_encoding_rev pypdf/_codecs/__init__.py Reverse encoding dict never referenced, not in __all__
_mac_encoding_rev pypdf/_codecs/__init__.py Reverse encoding dict never referenced, not in __all__
_symbol_encoding_rev pypdf/_codecs/__init__.py Reverse encoding dict never referenced, not in __all__
_zapfding_encoding_rev pypdf/_codecs/__init__.py Reverse encoding dict never referenced, not in __all__

_pdfdoc_encoding_rev is kept — it is used in generic/_base.py and exported in __all__.

Test plan

  • Each symbol has zero references in the entire repo (confirmed via grep)
  • No imports broken

Found with Skylos — dead code detection for Python.

- Remove FieldFlag (constants.py) — IntFlag class never used or imported anywhere
- Remove _win_encoding_rev, _mac_encoding_rev, _symbol_encoding_rev, _zapfding_encoding_rev (_codecs/__init__.py) — reverse encoding dicts never referenced anywhere, not in __all__. _pdfdoc_encoding_rev is kept as it is used in generic/_base.py and exported in __all__.

Identified via static analysis (zero references across entire codebase for each symbol).
@codecov

codecov Bot commented Mar 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.41%. Comparing base (8f1f4aa) to head (fd10622).
⚠️ Report is 121 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3685      +/-   ##
==========================================
- Coverage   97.41%   97.41%   -0.01%     
==========================================
  Files          55       55              
  Lines        9989     9985       -4     
  Branches     1833     1833              
==========================================
- Hits         9731     9727       -4     
  Misses        150      150              
  Partials      108      108              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@stefan6419846 stefan6419846 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not mix multiple changes into one PR.

Additionally, removing public attributes requires a deprecation process.

@duriantaco

Copy link
Copy Markdown
Contributor Author

hi split done.. reverted the FieldFlag change since it's public and would need deprecation. This PR removes the four private _*_encoding_rev dicts which are underscore-prefixed, excluded from all, and unreferenced in the codebase.

@stefan6419846 stefan6419846 changed the title DEV: remove unused FieldFlag class and reverse encoding dicts DEV: Remove unused reverse encoding dicts Mar 16, 2026
@stefan6419846
stefan6419846 merged commit 87aa1d4 into py-pdf:main Mar 16, 2026
19 checks passed
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.

2 participants