Skip to content

Add ability to select path segments using Python re regexprs; follow on to PR#146 #177

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

Closed
wants to merge 16 commits into from

Conversation

AlainLich
Copy link

Hi, this is a follow-on of my previous PR (#146) on same subject; apparently it was simpler for me to use a different branch.

This has run Action https://github.com/AlainLich/dpath-python/actions/runs/3684590771 in my branch AL-master4merge. I have added tests exercising this with most functions, and documented in README.rst

All details are in the list of commits, including documentation, tests,...

I hope this suits your needs, let me know if there are still issues for merging in the main baseline.

Recovered 1) tests/test_path_ext_py from PR submission
2) some github workflows used to validate PR submission
    Follow-up PR: "Add ability to select path segments using Python re regexprs" dpath-maintainers#146
 	          on June 1, 2021

    Includes:
            - integration of extension on dpath-python
            - improvement of tests (under nose2, with scripts test/noseRunner to control code options)
            - improvement of documentation in README.rst

    Baseline for integration:
            commit ea64635 (tag: v2.1.1, origin/master, origin/HEAD, master, AL-master4merge)
            Merge: 702b5dd 38007df
            Author: moomoohk <[email protected]>
            Date:   Wed Nov 30 17:16:05 2022 +0200

    Note: at this time, no test wrt. Github.Actions has been made (yet)
Resolved conflicts:
	dpath/segments.py
	dpath/version.py

Testing to be redone!
        - tests improved and running locally
	- documentation updated

Follow-up PR: "Add ability to select path segments using Python re regexprs" dpath-maintainers#146
              on June 1, 2021

Baseline for merge:
    commit 45b3488 (tag: v2.1.2, origin/master, origin/HEAD, master)
    Author: moomoohk <[email protected]>
    Date:   Mon Dec 5 09:52:05 2022 +0200
…on enhancements

1) suppress dependency on mock now integrated as unittest.mock
2) avoids warnings concerning invalid escape sequences: either use raw strings or
   use double backslash: testing both
3) detailed the issue of such escape sequences in re.regexp in README.rst,
   giving example of both techniques

No change in .yml: rerunning should resolve identified issues
moomoohk and others added 5 commits December 17, 2022 18:12
…path for pypy

    - Improved Github actions (clean up, test under pypy3)
    - formatting in accordance with Flake8, deal with errors diagnosed by Flake but
	accepted by python3
    - moved test tools to dir test-utils
    - tox.ini, flake.ini: avoid spurious diagnostics
…ing StringMatcher capability:

     1) supports extension by re.regex (re.Pattern.match)
     2) supports duck typed Duck_StringMatcher derived classes which permit user defined pattern matcher
     3) included tests and documenation
     4) dealt with Flake8 diagnostics

    Also found a random rare error in test_segments.test_view, left Pdb obtained information in the source
    file (see bottom of tests/test_segments.py). This corresponds with an unrealistic situation random
    generated by hypothesis, not easily reproducible for lack of random seed.
@AlainLich
Copy link
Author

Hi @moomoohk

  • after looking at yesterday's tests, failure was apparently caused by lack of support for typing.Protocol, which implements https://peps.python.org/pep-0544/ , because pypy's version was older than the one I have been using.

  • I am preparing an improved version that supports both PEP-544 compliant and ignorant compilers, with a little bit more work for the user in the latter case.

  • Apparently most of the work TBD is in the testing, so don't expect a revised version before next week-end.

@moomoohk
Copy link
Collaborator

Hi Alain,
I've cleared enough from the backlog and now I'd like to focus on your PR.
After reviewing the changes you've made it's clear a lot of work has been put in and that's much appreciated.
That said, I feel that a lot of the changes included aren't within the scope of the feature addition you're proposing.

If the core functionality (adding regexes to paths) works well enough then I'd like to restructure this PR. I hope that's ok with you!

Perhaps the other changes can be considered separately.

Thanks.

@AlainLich
Copy link
Author

AlainLich commented Jan 10, 2023 via email

@AlainLich
Copy link
Author

AlainLich commented Jan 11, 2023 via email

AlainLich and others added 4 commits January 11, 2023 17:49
Deals with
 - issues testing with pypy (an possibly some older Pythons)
 - flake8 diagnostics

Other developments to go to separate PR
@AlainLich
Copy link
Author

Hi @moomoohk

a) this is fine, do you expect me to do anything?
b) while you are on this, could you make your workflow "deploy" dependent on your user name; the way things are set up now, each time I pull master for synchronising (and if the version has changed), it launches (under my name) and
fails as it should... and I get some spurious mail. ( https://github.com/AlainLich/dpath-python/actions/runs/3900678773)

Something like the following should work (not tried):

deploy:
   ... 
    # Check that this only occurs on maintainer repo
    if: ${{ github.actor == "dpath-maintainers" }} 

Have a good day :-)

@moomoohk
Copy link
Collaborator

moomoohk commented Apr 5, 2023

Hi Alain

Hi @moomoohk

a) this is fine, do you expect me to do anything? b) while you are on this, could you make your workflow "deploy" dependent on your user name; the way things are set up now, each time I pull master for synchronising (and if the version has changed), it launches (under my name) and fails as it should... and I get some spurious mail. ( https://github.com/AlainLich/dpath-python/actions/runs/3900678773)

Something like the following should work (not tried):

deploy:
   ... 
    # Check that this only occurs on maintainer repo
    if: ${{ github.actor == "dpath-maintainers" }} 

Have a good day :-)

Hi Alain,
I might have some time to go through your changes over the next few days.
I would much appreciate if you could open a separate PR/restructure this one to include the necessary changes for your proposed features.
I'll be glad to review miscellaneous infrastructure changes in a separate PR.
As it stands, the miscellaneous changes are blocking your feature.

Thanks and regards

# https://peps.python.org/pep-0604/#isinstance-and-issubclass
# https://bugs.python.org/issue44529

try:
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is this check needed for?

@@ -6,6 +6,12 @@
from dpath.exceptions import InvalidGlob, InvalidKeyName, PathNotFound
from dpath.types import PathSegment, Creator, Hints, Glob, Path, SymmetricInt

import re
try:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Dpath's minimum supported version is Python 3.7 making this check redundant

@AlainLich
Copy link
Author

Hi @moomoohk,
I will try to look into this before the end of next week-end. I will send you a few questions about what to keep in the mean time. Will keep the bare minimum for the feature to work, and for tests, and prepare a PR based on current master commit.

For now:
a) do you want to always enable the feature ? to allow enabling/disablig by DPATH_ACCEPT_RE_REGEXP ?
b) I will review tests I have added for their usefulness

Regards

@AlainLich
Copy link
Author

Hi @moomoohk
following your remarks, I submitted PR #186 as replacement for this one, with only required changes. This PR #177 can be closed.

You were right to spot not needed stuff, some that can be assumed for Python >= 3.7, others that were left from my exercise with duck-typed generalization.

Regards
Alain

@moomoohk
Copy link
Collaborator

May we close this PR for the time being?

@moomoohk moomoohk closed this Apr 15, 2023
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