diff --git a/docs/python/environment-and-dependency.md b/docs/python/environment-and-dependency.md index 34311b5..d8964f0 100644 --- a/docs/python/environment-and-dependency.md +++ b/docs/python/environment-and-dependency.md @@ -15,7 +15,9 @@ sidebar_label: Environment Isolation and Dependency Management - [venv](https://docs.python.org/3/tutorial/venv.html). _Inbuilt_ `python -m venv` * Use `pip` for installing packages if not using `poetry`. - +:::info +Docker based containerized python can be used as well. Official images [here](https://hub.docker.com/_/python). It is better to use virtualenvs in docker as well rather than root based user. +::: ### Dependency Management: diff --git a/docs/python/general.md b/docs/python/general.md index 8212843..b84441a 100644 --- a/docs/python/general.md +++ b/docs/python/general.md @@ -11,7 +11,7 @@ It is recommended to upgrade the package dependency whenever possible although v ::: * See [tools](tools.md) that can be used in development environment setup to ease your coding process. -* Always use `python3` and try to stay above version `3.7`. **Latest stable** is always recommended. +* Always use `python3`. **Latest stable** is always recommended. Ensure version is no older than 2 versions back. i.e. if current stable is `3.11` then use atleast `3.9`. * Indentation should always be **space** and width should always be **4**. * File size and functionality: - break files into modules if you feel they have multiple functionalities. @@ -41,7 +41,7 @@ It is recommended to upgrade the package dependency whenever possible although v WHEN break DOESNOT HAPPEN ``` * Use `pathlib` for path related use case rather than `os.path` -* Use type annotation or type hints when possible for type safe code. `mypy` like checker can be used. +* Use type annotation or type hints for type safe code especially for newer projects. Look into [tools](tools.md) for inference checker. * `Docker` can be used for deployment. Use `python` images for [`docker`](https://hub.docker.com/_/python). * Use `generators` and `yield` instead of data structures for high streams of data. * Use `itertools`, `functools` for utilities and `collections` for data structures when needed. diff --git a/docs/python/tools.md b/docs/python/tools.md index 32f9bcf..a7216b1 100644 --- a/docs/python/tools.md +++ b/docs/python/tools.md @@ -24,6 +24,7 @@ These can be used with dependency Management ### Linters: * [flake8](https://flake8.pycqa.org/en/latest/) with [plugins](https://github.com/DmytroLitvinov/awesome-flake8-extensions) * Alternative: [pylint](https://www.pylint.org) + * Alternative: [ruff](https://beta.ruff.rs/docs/) * [bandit](https://bandit.readthedocs.io/en/latest/) to find common security issues. This can be used with `flake8` as a [plugin](https://pypi.org/project/flake8-bandit/) ### Formatters: @@ -32,6 +33,13 @@ These can be used with dependency Management - Alternative: [yapf](https://pypi.org/project/yapf/) * [isort](https://timothycrosley.github.io/isort/) for sorting only imports in codes. This is OPTIONAL. - Alternative: [reorder-python-imports](https://github.com/asottile/reorder_python_imports) another way of sorting imports. + + +### Type Inference +* [mypy](http://mypy-lang.org/index.html) optional static type coding with python through annotations. from Dropbox but most famous in community. + - Alternative: [pyright](https://github.com/microsoft/pyright#readme) from Microsoft. Usually available in VSCode + - Alternative: [pyre](https://pyre-check.org/) from Facebook. + - Alternative: [pytype](https://google.github.io/pytype/) from Google. ### Testing: * [pytest](https://pytest.org) with [plugins](https://docs.pytest.org/en/7.0.x/reference/plugin_list.html) @@ -45,7 +53,8 @@ These can be used with dependency Management * [factory_boy](https://factoryboy.readthedocs.io/en/stable/index.html) for fixture generation. * [coverage](https://coverage.readthedocs.io/en/coverage-5.1/) for checking code coverage of tests. * [interrogate](https://interrogate.readthedocs.io/en/latest/) for docstring coverage check. -* [mypy](http://mypy-lang.org/index.html) optional static type coding with python through annotations. + + ### Readings and References: * [Design Patterns](https://python-patterns.guide/)