Skip to content

Fix #242: Add type parameters to PRecord for pylance/pyright compatib…#315

Merged
tobgu merged 3 commits intotobgu:masterfrom
VYaswanthKumar:VYaswanthKumar-patch-1
Oct 22, 2025
Merged

Fix #242: Add type parameters to PRecord for pylance/pyright compatib…#315
tobgu merged 3 commits intotobgu:masterfrom
VYaswanthKumar:VYaswanthKumar-patch-1

Conversation

@VYaswanthKumar
Copy link
Copy Markdown
Contributor

…ility

@tobgu
Copy link
Copy Markdown
Owner

tobgu commented Oct 20, 2025

Hi!

There seems to be quite a lot of changes going into this PR that I\m not sure are related to the intent as expressed by the PR title. Furthermore some of them are backwards incompatible (see failing tests for some examples) which is pretty much a no-no unless there is good reasons for it.

Thanks

This commit reverts all backwards incompatible changes that were introduced in the previous version:

- Restored CheckedType.create() method with ignore_extra parameter support
- Restored PRecord.set() method signature to accept *args, **kwargs
- Restored _PRecordEvolver to properly inherit from PMap._Evolver
- Fixed AttributeError by restoring correct is_field_ignore_extra_complaint() call
- Restored _ignore_extra parameter throughout the evolver implementation

The ONLY change from master is adding type parameters [str, Any] to PRecord class definition:
class PRecord(PMap[str, Any], CheckedType, metaclass=_PRecordMeta)

This minimal change provides pylance/pyright compatibility while maintaining full backwards compatibility.
@VYaswanthKumar
Copy link
Copy Markdown
Contributor Author

Hi @tobgu,

I've added a new commit (88e2884) that fixes the backward compatibility issues you mentioned. The previous failing tests were caused by:

  1. AttributeError: 'str' object has no attribute 'type' - The is_field_ignore_extra_complaint function in _precord.py was being called with PRecord as the first argument instead of CheckedType, causing type checking errors.

  2. TypeError: CheckedType.create() got an unexpected keyword argument 'ignore_extra' - The abstract create() method in CheckedType and the CheckedPMap.create() method didn't accept the ignore_extra parameter, even though it was being passed by code that checks for fields supporting this parameter.

Fixes applied:

  • Added ignore_extra=False parameter to CheckedType.create() abstract method in _checked_types.py (line 24)
  • Added ignore_extra=False parameter to CheckedPMap.create() method in _checked_types.py (line 383)
  • Fixed the call to is_field_ignore_extra_complaint in _precord.py (line 111) to use CheckedType instead of PRecord

These changes maintain backward compatibility while properly supporting the ignore_extra feature. Could you please review and approve the workflow so the tests can run? The fixes should resolve all the test failures.

Thank you!

@tobgu
Copy link
Copy Markdown
Owner

tobgu commented Oct 22, 2025

Looks good, thanks!

@tobgu tobgu merged commit 401eeff into tobgu:master Oct 22, 2025
5 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