From d4b3f98bf0f340b53e8d9998eef6fdfb447785c6 Mon Sep 17 00:00:00 2001 From: Diogo Rossi Date: Thu, 27 Jul 2023 17:28:48 -0300 Subject: [PATCH 1/5] fixing documentation of `CONTRIBUTING.md` indenting code blocks so they will be rendered as code blocks and become easy to copy from GitHub --- CONTRIBUTING.md | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1290a7e..1c1d8ee 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -13,7 +13,10 @@ The CI way This is the easiest/quickest way in terms of setup. -1. Clone pyside2-stubs +1. Create a fork pyside2-stubs + + +2. Clone your forked repo of pyside2-stubs 2. Add test showing the incorrect stub. For example, I noticed that QAction.setShortcut() was declared to support @@ -32,11 +35,11 @@ This is the easiest/quickest way in terms of setup. from: - def setShortcut(a: QKeySequence) -> None: ... + def setShortcut(a: QKeySequence) -> None: ... to: - def setShortcut(a: typing.Union[QKeySequence, str]) -> None: ... + def setShortcut(a: typing.Union[QKeySequence, str]) -> None: ... 4. Commit the change and push it to your repo. @@ -58,19 +61,19 @@ Here, you take all the steps to reproduce a complete stub testing environement t 2. Create a virtual environment (I used .env as a name for my virtual environment) and activate it. - $ python -m venv .env - $ .env\scripts\activate + python -m venv .env + .env\scripts\activate 3. Install the required packages for running the tests. - pip install -r dev-requirements.txt + pip install -r dev-requirements.txt 4. Make your current directory an editable installed package. - pip install -e . + pip install -e . Note: currently, with pip 22 and above, and mypy 0.971, the editable installation is not picked by mypy. For the CI, I need to force pip to version 21.2 for it to work. You may need to force pip also to this version. From 6d3fd5b7ba7a4ffefbf006de8a758a2d1b132c7e Mon Sep 17 00:00:00 2001 From: Diogo Rossi Date: Thu, 27 Jul 2023 17:28:48 -0300 Subject: [PATCH 2/5] add note to install requirements --- CONTRIBUTING.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1c1d8ee..1c3dce4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -67,8 +67,10 @@ Here, you take all the steps to reproduce a complete stub testing environement t 3. Install the required packages for running the tests. - pip install -r dev-requirements.txt + python -m pip install -r dev-requirements.txt + Note: running pip as a python module is necessary because dev-requirements.txt modify pip itself. + This can be confirmed by trying to run `pip install -r dev-requirements.txt` 4. Make your current directory an editable installed package. From 249c486cb232cb2bccdb12aff42e9db2ee81436a Mon Sep 17 00:00:00 2001 From: Diogo Rossi Date: Thu, 27 Jul 2023 17:36:54 -0300 Subject: [PATCH 3/5] small fixing of docs --- CONTRIBUTING.md | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1c3dce4..75e547e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -13,16 +13,16 @@ The CI way This is the easiest/quickest way in terms of setup. -1. Create a fork pyside2-stubs +1. Create a fork of `pyside2-stubs` -2. Clone your forked repo of pyside2-stubs +2. Clone your forked repo of `pyside2-stubs` -2. Add test showing the incorrect stub. For example, I noticed that QAction.setShortcut() was declared to support - only QKeySequence whereas a simple string is also supported. +3. Add test showing the incorrect stub. For example, I noticed that `QAction.setShortcut()` was declared to support + only `QKeySequence` whereas a simple string is also supported. - So I created a new file tests\qaction.py using the correct code usage, but detected incorrectly by mypy: + So I created a new file `tests\qaction.py` using the correct code usage, but detected incorrectly by mypy: from PySide2.QtWidgets import QAction @@ -30,7 +30,7 @@ This is the easiest/quickest way in terms of setup. a.setShortcut('Ctrl+F') -3. Fix the PySide2 stubs. In my case, I changed the signature of QAction.setShortcut() +4. Fix the PySide2 stubs. In my case, I changed the signature of `QAction.setShortcut()` from: @@ -42,10 +42,10 @@ This is the easiest/quickest way in terms of setup. def setShortcut(a: typing.Union[QKeySequence, str]) -> None: ... -4. Commit the change and push it to your repo. +5. Commit the change and push it to your repo. -5. Create a pull request against pyside2-stubs. The PR will run the CI for your change and ensure that all tests continue +6. Create a pull request against `pyside2-stubs`. The PR will run the CI for your change and ensure that all tests continue to pass successfully. I'll be happy to merge the result. @@ -56,23 +56,25 @@ The manual way Here, you take all the steps to reproduce a complete stub testing environement to include your change. -1. Clone pyside2-stubs +1. Create a fork of `pyside2-stubs` + +2. Clone your forked repo of `pyside2-stubs` -2. Create a virtual environment (I used .env as a name for my virtual environment) and activate it. +3. Create a virtual environment (I used `.env` as a name for my virtual environment) and activate it. python -m venv .env .env\scripts\activate -3. Install the required packages for running the tests. +4. Install the required packages for running the tests. python -m pip install -r dev-requirements.txt - Note: running pip as a python module is necessary because dev-requirements.txt modify pip itself. + Note: running pip as a python module is necessary because `dev-requirements.txt` modify pip itself. This can be confirmed by trying to run `pip install -r dev-requirements.txt` -4. Make your current directory an editable installed package. +5. Make your current directory an editable installed package. pip install -e . @@ -81,7 +83,7 @@ Here, you take all the steps to reproduce a complete stub testing environement t For the CI, I need to force pip to version 21.2 for it to work. You may need to force pip also to this version. -5. Make sure the tests run correctly as they are: +6. Make sure the tests run correctly as they are: $ pytest -v [...] @@ -91,7 +93,7 @@ Here, you take all the steps to reproduce a complete stub testing environement t There should be no failure reported. -6. Add test showing the incorrect stub definitions. For example, I noticed that `QAction.setShortcut()` was declared to support +7. Add test showing the incorrect stub definitions. For example, I noticed that `QAction.setShortcut()` was declared to support only `QKeySequence` whereas a simple string is also supported. So I created a new file `tests\qaction.py` using the correct code usage, but detected incorrectly by mypy: @@ -102,7 +104,7 @@ Here, you take all the steps to reproduce a complete stub testing environement t a.setShortcut('Ctrl+F') -7. Run the tests again. Your new file should be picked up and reported as an error by the mypy test. +8. Run the tests again. Your new file should be picked up and reported as an error by the mypy test. (.env2) c:\oss\PyQt-stubs\PySide2-stubs>pytest -v @@ -156,7 +158,7 @@ Here, you take all the steps to reproduce a complete stub testing environement t Note that you can run your new test only by uing: pytest -k "your test name" -v -8. Fix the PySide2 stubs. In my case, I changed the signature of QAction.setShortcut() +9. Fix the PySide2 stubs. In my case, I changed the signature of `QAction.setShortcut()` from: @@ -167,7 +169,7 @@ Here, you take all the steps to reproduce a complete stub testing environement t def setShortcut(a: typing.Union[QKeySequence, str]) -> None: ... -9. Rerun the tests. If it looks like mypy is still using the old stubs, delete .mypy-cache . It helps. +10. Rerun the tests. If it looks like mypy is still using the old stubs, delete `.mypy-cache` . It helps. You should now see no error, but two more tests successful. $ pytest -v @@ -175,6 +177,6 @@ Here, you take all the steps to reproduce a complete stub testing environement t ================================================= 62 passed in 13.07s ================================================= $ -10. Commit your changes and push them to your repository. +11. Commit your changes and push them to your repository. -11. Create a pull request. I'll be glad to merge it. The CI will run basically the same tests that you did over your changes. +12. Create a pull request. I'll be glad to merge it. The CI will run basically the same tests that you did over your changes. From 132408b75bf233ff93a4b82befbdca98238893b6 Mon Sep 17 00:00:00 2001 From: Diogo Rossi Date: Thu, 27 Jul 2023 22:06:16 -0300 Subject: [PATCH 4/5] correct typo --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 75e547e..c695755 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -54,7 +54,7 @@ This is the easiest/quickest way in terms of setup. The manual way -------------- -Here, you take all the steps to reproduce a complete stub testing environement to include your change. +Here, you take all the steps to reproduce a complete stub testing environment to include your change. 1. Create a fork of `pyside2-stubs` @@ -155,7 +155,7 @@ Here, you take all the steps to reproduce a complete stub testing environement t (.env2) c:\oss\PyQt-stubs\PySide2-stubs> - Note that you can run your new test only by uing: pytest -k "your test name" -v + Note that you can run your new test only by using: `pytest -k "your test name" -v` 9. Fix the PySide2 stubs. In my case, I changed the signature of `QAction.setShortcut()` From af68b35502ea99da96381c60cbc7b5ac7abadb19 Mon Sep 17 00:00:00 2001 From: Diogo Rossi Date: Thu, 27 Jul 2023 22:06:35 -0300 Subject: [PATCH 5/5] add `**/__pycache__` to `.gitignore` --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index d84968b..5263222 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ /dist/ /PySide2_stubs.egg-info .mypy_cache +**/__pycache__