Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test the Union Operator on dictionaries #53

Merged
merged 6 commits into from
Mar 15, 2024
Merged

Conversation

brocla
Copy link
Contributor

@brocla brocla commented Mar 12, 2024

Hello @BethanyG . This PR has four code snippets to test the union operator ( | and |= ) on dictionaries.

a) I got chatGPT to suggest an example :-) I included my prompt in the file. It is a function to merge user settings with some default settings.

b) This one comes from examples in PEP584 (Add Union Operators To dict).

c) The third example comes from the Cpython unit tests.

d) The last one comes from the alphametrics exercise. I modified a call to the .union() method, to use the operator instead.

This comment was marked as resolved.

@github-actions github-actions bot closed this Mar 12, 2024
@BethanyG
Copy link
Member

Hi there @brocla! Thank you for this. 😄

I am running behind in life, so haven't gotten to this or your previous PR -- but hopefully will do so before EOD tomorrow.

-B

@BethanyG BethanyG reopened this Mar 12, 2024
@BethanyG
Copy link
Member

Uh. Oh. This is currently failing CI. I think that's because the toml library has been deprecated for Python, and Python 3.11+ now has the tomlib module in its place.

image

I will check later today (or if you have time, you can) -- but we probably need to slightly rewrite the ChatGPT example. Its going off of historical/bad data. 😄

@BethanyG BethanyG self-requested a review March 12, 2024 23:46
@brocla
Copy link
Contributor Author

brocla commented Mar 13, 2024 via email

  - delete leading and trailing blank lines
@brocla
Copy link
Contributor Author

brocla commented Mar 13, 2024 via email

Copy link
Member

@BethanyG BethanyG left a comment

Choose a reason for hiding this comment

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

Nice work! Added adapted examples from Mecha Munch Management, and had a few other suggestions/suggested removals. LMK if you have questions or issues.

I can merge later today, after we finalize things. 😄

Be explict about dictionaries.
@brocla
Copy link
Contributor Author

brocla commented Mar 15, 2024 via email

…zation.py


The second argument here needs to be an iterable, and dicts only iterate over keys,  but we need keys and values.
@BethanyG
Copy link
Member

Hi Bethany, Yes, it might be time to let go. We can use three exercises that we have already written for unions. They will protect us in the case that an astor version of the Representer sneaks back in. BTW I installed an older version of python (3.8.13) to show that ast would not parse and unparse a tiny example. But it failed for an unexpected reason: ast has no attribute unparse !?! It turns out that unparse() is new in python 3.9. I don't think the python developers are going to spend much time making unparse work for releases that are older than the feature.

import ast >> ast.unparse(ast.parse('{} | {}'))
Traceback (most recent call last): File "", line 1, in AttributeError: module 'ast' has no attribute 'unparse'

Yup. 💙 I also ran into that. And since 3.7 is already EOL, and 3.8 is due to EOL in October, well....

So I agree: we have some good examples, and we've both beaten and tested the "dead horse", so to speak. 😆 I am going to merge as soon as I fix the CI.

Due to some small code review changes, had to re-record the representation.
@BethanyG BethanyG merged commit 0e67a90 into exercism:main Mar 15, 2024
1 check passed
@brocla
Copy link
Contributor Author

brocla commented Mar 16, 2024 via email

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