returns icon indicating copy to clipboard operation
returns copied to clipboard

Issue 1114

Open CucumisSativus opened this issue 4 years ago • 6 comments

I have made things!

Checklist

  • [X] I have double checked that there are no unrelated changes in this pull request (old patches, accidental config files, etc)
  • [X] I have created at least one test case for the changes I have made
  • [X] I have updated the documentation for the changes I have made
  • [X] I have added my changes to the CHANGELOG.md

Related issues

Refs #1114

A simple implementation of filter for maybe. I am happy to implement something similar for Result, but I'm not entirely sure about the preferred approach. In Scala it looks more or less like this

      if (p(value)) this else Failure(new NoSuchElementException("Predicate does not hold for " + value))

Not sure if something like this is ok for Python as well.

My second idea was to have a signature like

def filter(predicate, on_failure):
(...)

so user can specify exactly what happens in case of not matching predicate 🙏 Please, if you or your company finds dry-python valuable, help us sustain the project by sponsoring it transparently on https://github.com/sponsors/dry-python. As a thank you, your profile/company logo will be added to our main README which receives hundreds of unique visitors per day.

CucumisSativus avatar Nov 16 '21 20:11 CucumisSativus

We also need to make an interface type for filter. This way we will be able to use with HKT. See interfaces/ folder.

sobolevn avatar Nov 16 '21 21:11 sobolevn

@sobolevn I think i managed to add them, but lets say i'm not 100% sure about those. Looking forward for some feedback :)

CucumisSativus avatar Nov 18 '21 06:11 CucumisSativus

@sobolevn when i'm running poetry run pytest typesafety -p no:cov -o addopts="" --mypy-ini-file=setup.cfg locally I get 830 passed, 1 warning. Any ideas why does it fail on github?

CucumisSativus avatar Nov 23 '21 20:11 CucumisSativus

I will take a look a bit later this week.

Thanks a lot for the PR!

sobolevn avatar Nov 23 '21 22:11 sobolevn

@sobolevn i think I found it

CucumisSativus avatar Dec 11 '21 21:12 CucumisSativus

Codecov Report

Merging #1131 (cca6894) into master (b782c2e) will not change coverage. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master     #1131   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           79        81    +2     
  Lines         2415      2450   +35     
  Branches       208       210    +2     
=========================================
+ Hits          2415      2450   +35     
Impacted Files Coverage Δ
returns/interfaces/filterable.py 100.00% <100.00%> (ø)
returns/maybe.py 100.00% <100.00%> (ø)
returns/pointfree/__init__.py 100.00% <100.00%> (ø)
returns/pointfree/filter.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update b782c2e...cca6894. Read the comment docs.

codecov[bot] avatar Dec 12 '21 08:12 codecov[bot]