-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add --init command - Add activate.bat - Documentation
- Loading branch information
Niko Pasanen
committed
Dec 20, 2020
1 parent
bf2a2f2
commit d222e53
Showing
10 changed files
with
471 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Contributing | ||
|
||
This is the workflow on how one would contribute on this project. | ||
|
||
1) Fork this project on GitHub | ||
2) Clone the fork of venv from GitHub to your own PC | ||
3) Create a virtual environment and activate it. Install venvlink to the virtual environment in *editable state* with | ||
|
||
``` | ||
pip install -e . | ||
``` | ||
where `.` denotes the current directory. If you're not in the project root directory navigate into it, or replace `.` with full filepath pointing to the folder with the `setup.py`. (remember to quote the path if it contains spaces) | ||
|
||
also install `pytest` with `pip`. | ||
|
||
4) Make some changes | ||
5) Write test for the changes, if applicable, to the `tests` folder. The naming convention is `test_<higher-level-topic>.py`. Inside the test modules, write functions with name `test_name_of_the_test`. This way they are discovered automatically by `pytest`. | ||
6) Run tests with | ||
|
||
``` | ||
python -m pytest .\tests | ||
``` | ||
|
||
7) When tests look ok, and you are happy with the code, stage the changes, and commit them, one piece at a time. Try to have *atomic* (small) commits, and not one large commit with *lots* of stuff inside it. | ||
8) Git push to your fork in GitHub | ||
9) Create pull request on GitHub. Usually there is some discussion about the changes and perhaps some iterations before the changes are merged. | ||
|
||
As a general tip (applies to any open source project), if you have very wild ideas, it is better to discuss with the maintainer(s) about it before implementing it, for example in a GitHub Issue. This way the contribution is most effective. |
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
|
||
## Usage with linters (e.g. pylint) | ||
|
||
Linters like `pylint` try to search for the packages intelligently from a virtual environment, if such exists. Placing virtual environment files outside of `<project>\venv\`, to for example `C:\Python\venvs\myproj` will have the side effect that linters might not find your modules. This might cause false positive `import-error`s, like the one below. | ||
|
||
 | ||
|
||
### Fixing false positive `import-error`s | ||
You have to tell to the linter that you are using, where to look for the modules. | ||
|
||
**`pylint`**<br><br> | ||
Add following init hook | ||
|
||
``` | ||
--init-hook "import sys; sys.path.insert(0, 'C:/Python/venvs/myenv/Lib/site-packages')" | ||
``` | ||
- Replace `'C:/Python/venvs/myenv'` with the virtual environment path of your project | ||
- Note that the path separator is ***forward*** slash `/` | ||
|
||
|
||
**VSCode & `pylint`**<br><br> | ||
To configure `pylint` in VSCode, you need to | ||
- Open `Preferences: Open Workspace Settings (JSON)` (Ctrl+Shift+P) | ||
- Add there the following: | ||
|
||
```json | ||
{ | ||
"python.linting.pylintArgs": [ | ||
"--init-hook", | ||
"import sys; sys.path.insert(0, 'C:/Python/venvs/myenv/Lib/site-packages')", | ||
"--disable=all", | ||
"--enable=F,E,unreachable,duplicate-key,unnecessary-semicolon,global-variable-not-assigned,unused-variable,binary-op-exception,bad-format-string,anomalous-backslash-in-string,bad-open-mode" | ||
], | ||
} | ||
``` | ||
- The `--disable=all` and `--enable=...` are optional, but you want to keep them if you are not using a `pylintrc` file, and you are used to the [default filtering VSCode does for you](https://code.visualstudio.com/docs/python/linting#_default-pylint-rules). |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.