Skip to content

Group mapping values instead of mapping keys - #456

Open
ainuo-AI wants to merge 1 commit into
dgilland:developfrom
ainuo-AI:fix/group-mapping-values
Open

ainuo-AI wants to merge 1 commit into
dgilland:developfrom
ainuo-AI:fix/group-mapping-values

Conversation

@ainuo-AI

Copy link
Copy Markdown

group_by() iterates mapping keys directly, unlike the other collection helpers. For example, group_by({'first': 1, 'second': 3}, parity) passes the strings 'first' and 'second' to a numeric callback, while the default iteratee produces groups of keys instead of values.

Group Mapping.values() with the existing loop. Add mapping-specific overloads and assert_type regressions, cover dict/UserDict/read-only MappingProxyType with identity, callable and shorthand iteratees, and add a dictionary example. Update the changelog and contributor list.

Validation on Windows / CPython 3.12.10:

  • All 12 new runtime regressions fail on unchanged upstream and pass after this fix.
  • Standard unit/doctest suite, using inv test's source/test ordering and exclusion of the legacy type-snapshot directory: 3336 passed, 100% coverage.
  • The new assert_type regression runs separately with pytest-mypy-testing and passes.
  • Ruff check/changed-file formatting, mypy over src/pydash, tests and tasks.py (30 files), and git diff --check pass.

The full supported interpreter/OS matrix was not run locally. AI assistance: OpenAI Codex was used for investigation, implementation and running the validation commands.

@dgilland dgilland left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Lint check is failing on mypy:

Running mypy
  tests/test_objects.py:342:9: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs  [annotation-unchecked]
  ERROR: src/pydash/chaining/all_funcs.pyi is out of date. Please run `inv generate-chaining-types` and commit the changes.
  PASSED
  
  Running chaining-types-update-required
  ERROR: linters failed: chaining-types-update-required
  FAILED

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