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

Add type Path on web app run #6843

Merged
merged 13 commits into from Jul 24, 2022
Merged

Add type Path on web app run #6843

merged 13 commits into from Jul 24, 2022

Conversation

SamirPS
Copy link
Contributor

@SamirPS SamirPS commented Jul 23, 2022

What do these changes do?

I modify the web.py file and add Union[str,pathlib.Path] for path

Are there changes in behavior for the user?

For the option of path, we can have str or pathlib.path

Related issue number

#6839

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes
  • If you provide code modification, please add yourself to CONTRIBUTORS.txt
    • The format is <Name> <Surname>.
    • Please keep alphabetical order, the file is sorted by names.
  • Add a new news fragment into the CHANGES folder
    • name it <issue_id>.<type> for example (588.bugfix)
    • if you don't have an issue_id change it to the pr id after creating the pr
    • ensure type is one of the following:
      • .feature: Signifying a new feature.
      • .bugfix: Signifying a bug fix.
      • .doc: Signifying a documentation improvement.
      • .removal: Signifying a deprecation or removal of public API.
      • .misc: A ticket has been closed, but it is not of interest to users.
    • Make sure to use full sentences with correct case and punctuation, for example: "Fix issue with non-ascii contents in doctest text files."

@psf-chronographer psf-chronographer bot added the bot:chronographer:provided There is a change note present in this PR label Jul 23, 2022
@SamirPS
Copy link
Contributor Author

SamirPS commented Jul 23, 2022

@Dreamsorcerer Here the new

@SamirPS
Copy link
Contributor Author

SamirPS commented Jul 23, 2022

The previous error was due to a python library ?

@Dreamsorcerer
Copy link
Member

The previous error was due to a python library ?

Mypy gets its type information from typeshed, which is just a collection of annotations, because cpython doesn't have any annotations itself.

@Dreamsorcerer
Copy link
Member

So, that error will disappear when there's a new mypy release which will include the updated typeshed.

@SamirPS
Copy link
Contributor Author

SamirPS commented Jul 23, 2022

Oh okay thanks for the information

now we have this error : aiohttp/web_runner.py:199: error: Incompatible return value type (got "Union[str, Path]", expected "str") [return-value]

I need to change str to Union[str, Path] for the name(self) function ?

@Dreamsorcerer
Copy link
Member

You had partial changes to NamedPipeSite, I was just playing with them. I've reverted the change, as it's not clear to me whether someone would actually want to use a Path object, and the function it uses is undocumented.

@Dreamsorcerer Dreamsorcerer added the backport-3.9 Trigger automatic backporting to the 3.9 release branch by Patchback robot label Jul 23, 2022
@SamirPS
Copy link
Contributor Author

SamirPS commented Jul 23, 2022

Oh okay, use Path permit to avoid doing some convertion between Path and str i thinks

@SamirPS
Copy link
Contributor Author

SamirPS commented Jul 23, 2022

For the doc web_reference.rst how can i says str or Path :param str path: ?

@Dreamsorcerer
Copy link
Member

For the doc web_reference.rst how can i says str or Path :param str path: ?

Ah, good point. Take a look at add_static(), it mentions Path there: https://docs.aiohttp.org/en/stable/web_reference.html#aiohttp.web.UrlDispatcher.add_static

@codecov
Copy link

codecov bot commented Jul 23, 2022

Codecov Report

Merging #6843 (148badd) into master (934db9a) will increase coverage by 71.68%.
The diff coverage is 66.66%.

@@             Coverage Diff             @@
##           master    #6843       +/-   ##
===========================================
+ Coverage   21.76%   93.44%   +71.68%     
===========================================
  Files         104      104               
  Lines       30627    30629        +2     
  Branches     3076     3076               
===========================================
+ Hits         6666    28622    +21956     
+ Misses      23849     1838    -22011     
- Partials      112      169       +57     
Flag Coverage Δ
unit 93.36% <66.66%> (+71.62%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
tests/test_run_app.py 86.64% <0.00%> (+62.61%) ⬆️
aiohttp/web.py 99.17% <100.00%> (+70.84%) ⬆️
aiohttp/web_runner.py 92.37% <100.00%> (+52.73%) ⬆️
tests/autobahn/test_autobahn.py 38.33% <0.00%> (+6.66%) ⬆️
tests/test_circular_imports.py 100.00% <0.00%> (+7.69%) ⬆️
aiohttp/abc.py 100.00% <0.00%> (+7.86%) ⬆️
aiohttp/web_exceptions.py 99.52% <0.00%> (+22.27%) ⬆️
tests/conftest.py 68.42% <0.00%> (+25.43%) ⬆️
aiohttp/resolver.py 64.00% <0.00%> (+28.00%) ⬆️
aiohttp/tracing.py 100.00% <0.00%> (+36.12%) ⬆️
... and 87 more

Help us with your feedback. Take ten seconds to tell us how you rate us.

@SamirPS
Copy link
Contributor Author

SamirPS commented Jul 23, 2022

For the doc web_reference.rst how can i says str or Path :param str path: ?

Ah, good point. Take a look at add_static(), it mentions Path there: https://docs.aiohttp.org/en/stable/web_reference.html#aiohttp.web.UrlDispatcher.add_static

I just commit the change, i hope all test will pass

@SamirPS
Copy link
Contributor Author

SamirPS commented Jul 24, 2022

The test which fail it's because of a gcc error

@Dreamsorcerer Dreamsorcerer merged commit f90cb19 into aio-libs:master Jul 24, 2022
@patchback
Copy link
Contributor

patchback bot commented Jul 24, 2022

Backport to 3.9: 💔 cherry-picking failed — conflicts found

❌ Failed to cleanly apply f90cb19 on top of patchback/backports/3.9/f90cb1952c272936845b93a8f424b32e703d545c/pr-6843

Backporting merged PR #6843 into master

  1. Ensure you have a local repo clone of your fork. Unless you cloned it
    from the upstream, this would be your origin remote.
  2. Make sure you have an upstream repo added as a remote too. In these
    instructions you'll refer to it by the name upstream. If you don't
    have it, here's how you can add it:
    $ git remote add upstream https://github.com/aio-libs/aiohttp.git
  3. Ensure you have the latest copy of upstream and prepare a branch
    that will hold the backported code:
    $ git fetch upstream
    $ git checkout -b patchback/backports/3.9/f90cb1952c272936845b93a8f424b32e703d545c/pr-6843 upstream/3.9
  4. Now, cherry-pick PR Add type Path on web app run #6843 contents into that branch:
    $ git cherry-pick -x f90cb1952c272936845b93a8f424b32e703d545c
    If it'll yell at you with something like fatal: Commit f90cb1952c272936845b93a8f424b32e703d545c is a merge but no -m option was given., add -m 1 as follows intead:
    $ git cherry-pick -m1 -x f90cb1952c272936845b93a8f424b32e703d545c
  5. At this point, you'll probably encounter some merge conflicts. You must
    resolve them in to preserve the patch from PR Add type Path on web app run #6843 as close to the
    original as possible.
  6. Push this branch to your fork on GitHub:
    $ git push origin patchback/backports/3.9/f90cb1952c272936845b93a8f424b32e703d545c/pr-6843
  7. Create a PR, ensure that the CI is green. If it's not — update it so that
    the tests and any other checks pass. This is it!
    Now relax and wait for the maintainers to process your pull request
    when they have some cycles to do reviews. Don't worry — they'll tell you if
    any improvements are necessary when the time comes!

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

@Dreamsorcerer
Copy link
Member

If you could follow the steps above to get this in to 3.9, that'd be great.

@SamirPS
Copy link
Contributor Author

SamirPS commented Jul 24, 2022

I just do it @Dreamsorcerer and now i wait

@@ -290,7 +291,7 @@ async def _run_app(
*,
host: Optional[Union[str, HostSequence]] = None,
port: Optional[int] = None,
path: Optional[str] = None,
path: Optional[Union[str, Path]] = None,
Copy link
Member

Choose a reason for hiding this comment

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

@Dreamsorcerer I wonder if this should've been os.PathLike instead...

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, seems we even have a PathLike in typedefs.py.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i didn't see it, you want me to use it or keep path from Pathlib ?

Copy link
Member

Choose a reason for hiding this comment

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

I'm already on it. Updating a couple of other places too.
#6876

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You update this pull request ? #6874

Copy link
Member

Choose a reason for hiding this comment

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

You update this pull request ? #6874

No, backports must be as close to the original patch as possible, for traceability.

@webknjaz
Copy link
Member

3.9 backport PR: #6957.

webknjaz added a commit that referenced this pull request Sep 22, 2022
Co-authored-by: SamirAk <44325916+SamirPS@users.noreply.github.com>
Co-authored-by: Samir Akarioh <akariohsamir@yahoo.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-3.9 Trigger automatic backporting to the 3.9 release branch by Patchback robot bot:chronographer:provided There is a change note present in this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants