Skip to content

Conversation

d-maurer
Copy link
Contributor

Assignment expressions are helpful to get clearer and more concise code (in many situations).

Because the Python grammar allows only simple identifiers as target of those expressions, they should be safe (at least) in all contexts that allow assignments of the form variable = expr.

The Python (3.8) concrete grammar allows only identifier as target of assignment expressions; the abstract grammar, however, allows arbitrary expressions. This PR records an error when the target is not a Name (which corresponds to identifier in the concrete grammar) -- special handling would be necessary for more general targets.

@icemac
Copy link
Member

icemac commented Apr 24, 2020

@d-maurer Thank you for your PR. There is already a similar one: #175 I prefer the implementation you did over the one over there, but I'd like to see a test both for the happy code path and for the exception to make sure it will run successfully in future Python versions.

@d-maurer
Copy link
Contributor Author

d-maurer commented Apr 24, 2020 via email

@d-maurer d-maurer requested a review from icemac April 27, 2020 06:37
@d-maurer
Copy link
Contributor Author

@icemac I have added the wanted tests. I am not sure, however, whether you will like their location: I have put them into RestirctedPython/tests and there they are currently alone. Apparently, some configuration magic typically takes RestrictedPython tests from elsewhere (especially AccessControl).

@icemac
Copy link
Member

icemac commented May 8, 2020

@d-maurer In RestrictedPython we decided to put the tests outside the src directory: https://github.com/zopefoundation/RestrictedPython/tree/master/tests (I do not understand what you mean be the configuration magic happening.)

There are already helpers for determining the Python version in https://github.com/zopefoundation/RestrictedPython/blob/master/src/RestrictedPython/_compat.py

@d-maurer
Copy link
Contributor Author

d-maurer commented May 9, 2020 via email

@d-maurer
Copy link
Contributor Author

d-maurer commented May 9, 2020

Michael Howitz wrote at 2020-5-8 07:19 -0700:
@d-maurer In RestrictedPython we decided to put the tests outside the src directory
Why?
...

  • you need a rarely used zope.testrunner option (--test-path) that it finds the tests

Apparently, the RestrictedPython tests require pytest (as runner) and do not run with zope.testrunner at all. The (zope.testrunner) option --test-path allows it to find the test modules but it does not find tests in those modules.

@dataflake
Copy link
Member

I agree that the way this package is structured is a mess. I can't even figure out how to run tox without getting error messages. That test runner seems to dive into the entire site-packages in the virtual environment. I would like to help on this package but the way it is I feel unable to.

@dataflake
Copy link
Member

If you look into tox.ini you can see that the tests are run using pytest. The configuration for it is in setup.cfg, that's where it sets up the paths to look for tests. I have made a change on master to remove . from that list and just leave tests - having the current folder meant the test collector went into the library path inside that folder and pick up tests for all kinds of stuff (and subsequently spewing error messages). Now you can actually run bin/tox and get something meaningful. I have also changed the tox configuration to allow parallel runs with -pall, that makes the overall run a lot faster and you don't get those miles of text output that I guess someone at some time found useful.

@icemac can you look/review again so we can move forward?

Copy link
Member

@icemac icemac left a comment

Choose a reason for hiding this comment

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

LGTM.

@icemac
Copy link
Member

icemac commented Jul 10, 2020

@dataflake You are right this package is special – you can call it a mess. The idea behind this package was to use some more modern approaches. (The one moving the tests outside one src I still do not get, I personally see no gain in it.)

@dataflake
Copy link
Member

The main issue I see is that it uses tools and configurations that are completely out of step with all other packages. Approaching this package and helping out here is unnecessarily hard.

@dataflake dataflake merged commit 722800e into master Jul 10, 2020
@dataflake dataflake deleted the NamedExpr_support branch July 10, 2020 14:02
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.

3 participants