falconry / falcon

The no-magic web data plane API and microservices framework for Python developers, with a focus on reliability, correctness, and performance at scale.
https://falcon.readthedocs.io/en/stable/
Apache License 2.0
9.53k stars 945 forks source link

Added deprecation warning for add_link() method #1928

Closed abidahmadq closed 2 years ago

abidahmadq commented 3 years ago

Summary of Changes

Added deprecation warning to the add_link() method.

Related Issues

Related to issue https://github.com/falconry/falcon/issues/1803

Pull Request Checklist

abidahmadq commented 3 years ago

@vytas7 please take a look.

codecov[bot] commented 3 years ago

Codecov Report

Merging #1928 (cc92edb) into master (ddb4a03) will not change coverage. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master     #1928   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           63        63           
  Lines         6676      6677    +1     
  Branches      1239      1239           
=========================================
+ Hits          6676      6677    +1     
Impacted Files Coverage Δ
falcon/response.py 100.00% <100.00%> (ø)
falcon/util/deprecation.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 ddb4a03...cc92edb. Read the comment docs.

abidahmadq commented 3 years ago

@vytas7 what should i do about the deprecation warning?
`class LinkHeaderResource: def init(self): self._links = []

def append_link(self, *args, **kwargs):
    self._links.append((args, kwargs))

def on_get(self, req, resp):
    resp.text = '{}'

    append_link = None
    for args, kwargs in self._links:
        append_link = (
            resp.append_link if append_link is resp.add_link else resp.add_link  
        )
        append_link(*args, **kwargs) --> line which is emiting the error. 

`

How should i fix it? 1) remove the resp.add_link from the above line so it doesn't use the Alias. 2) Use @pytest.mark.filterwarnings to ignore the warnings. 3) Use with pytest.warns(UserWarning): to catch it.

CaselIT commented 3 years ago

I think you can use the same pattern as here: https://github.com/falconry/falcon/blob/fb0d68688b29ae518f98798c278a5815e40660ca/tests/test_response_media.py#L182-L189

vytas7 commented 3 years ago

Hi again @abidahmadq , just checking if you had a chance to work on the second batch of my comments?

abidahmadq commented 3 years ago

@vytas7 finding it confusing on how to proceed with this. Will take a look again on this weekend.

abidahmadq commented 2 years ago

Thanks @vytas7