Skip to content

Fix TypeError with yapf>=0.32 during config formatting - #283

Open
shihangan wants to merge 1 commit into
IDEA-Research:mainfrom
shihangan:fix-yapf-compatibility
Open

Fix TypeError with yapf>=0.32 during config formatting#283
shihangan wants to merge 1 commit into
IDEA-Research:mainfrom
shihangan:fix-yapf-compatibility

Conversation

@shihangan

Copy link
Copy Markdown

Problem

Training crashes immediately when using yapf >= 0.32 with the following error:
TypeError: FormatCode() got an unexpected keyword argument 'verify'
This occurs in util/slconfig.py line 317, where the config object is formatted before saving to logs/.../config_cfg.py.

Root Cause

yapf removed the verify parameter in version 0.32.0, but DINO still passes verify=True. Since most users now install yapf >= 0.32 by default (pip install yapf), this affects all new environments.

Solution

This PR adds a try-except fallback:

  • If yapf < 0.32 (old): verify=True works as before
  • If yapf >= 0.32 (new): catches TypeError and calls without the parameter

No behavior change — newer yapf versions perform verification internally by default.

Testing

Tested on:

  • yapf 0.31.0 (old): verify=True accepted, config file formatted correctly
  • yapf 0.40.2 (new): falls back to no parameter, config file formatted correctly
  • Training runs successfully on both versions

Checklist

  • Code follows the project's style guidelines
  • Tested with both old and new yapf versions
  • No functional changes to model training or inference

The 'verify' parameter was removed in yapf 0.32.0, causing training
to crash immediately with:
  TypeError: FormatCode() got an unexpected keyword argument 'verify'

This commit adds a try-except fallback to support both old (<0.32)
and new (>=0.32) yapf versions.

Tested on:
- yapf 0.31.0 (old): verify=True works
- yapf 0.40.2 (new): falls back to no verify parameter
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