From 68655ed919219bcacb7fb7f384eb2269dc879b0b Mon Sep 17 00:00:00 2001 From: Eugeny Konstantinov Date: Sat, 16 Sep 2023 14:38:29 +0300 Subject: [PATCH] initial commit --- .github/workflows/golangci-lint.yml | 25 ++++ .github/workflows/python.yml | 34 +++++ README.md | 30 ++++ golang/.golangci.yml | 111 +++++++++++++++ golang/.vscode/launch.json | 18 +++ golang/.vscode/settings.json | 4 + golang/README.md | 34 +++++ golang/go.mod | 5 + golang/go.sum | 17 +++ golang/informatics.code-workspace | 18 +++ golang/internal/sample.go | 5 + golang/main.go | 7 + golang/tests/sample_test.go | 14 ++ python/.flake8 | 3 + python/.gitignore | 206 ++++++++++++++++++++++++++++ python/.vscode/launch.json | 15 ++ python/.vscode/settings.json | 7 + python/Pipfile | 19 +++ python/Pipfile.lock | 106 ++++++++++++++ python/README.md | 54 ++++++++ python/informatics.code-workspace | 19 +++ python/requirements.txt | Bin 0 -> 646 bytes python/src/__init__.py | 0 python/src/main.py | 7 + python/tests/__init__.py | 0 python/tests/test_main.py | 37 +++++ 26 files changed, 795 insertions(+) create mode 100644 .github/workflows/golangci-lint.yml create mode 100644 .github/workflows/python.yml create mode 100644 README.md create mode 100644 golang/.golangci.yml create mode 100644 golang/.vscode/launch.json create mode 100644 golang/.vscode/settings.json create mode 100644 golang/README.md create mode 100644 golang/go.mod create mode 100644 golang/go.sum create mode 100644 golang/informatics.code-workspace create mode 100644 golang/internal/sample.go create mode 100644 golang/main.go create mode 100644 golang/tests/sample_test.go create mode 100644 python/.flake8 create mode 100644 python/.gitignore create mode 100644 python/.vscode/launch.json create mode 100644 python/.vscode/settings.json create mode 100644 python/Pipfile create mode 100644 python/Pipfile.lock create mode 100644 python/README.md create mode 100644 python/informatics.code-workspace create mode 100644 python/requirements.txt create mode 100644 python/src/__init__.py create mode 100644 python/src/main.py create mode 100644 python/tests/__init__.py create mode 100644 python/tests/test_main.py diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml new file mode 100644 index 00000000..ec41a170 --- /dev/null +++ b/.github/workflows/golangci-lint.yml @@ -0,0 +1,25 @@ +name: golangci-lint +on: [push, pull_request] + +jobs: + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/setup-go@v3 + with: + go-version: 1.17 + - uses: actions/checkout@v3 + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version + version: v1.50.1 + working-directory: golang + args: -v --print-resources-usage --timeout=180s --config=.golangci.yml + - name: Test + run: | + cd golang + go test -count=1 -p 1 -v ./... + + \ No newline at end of file diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml new file mode 100644 index 00000000..876005b1 --- /dev/null +++ b/.github/workflows/python.yml @@ -0,0 +1,34 @@ +name: Python package + +on: [push, pull_request] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.9"] + + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + cd ./python + pip install -r requirements.txt + - name: Lint with flake8 + run: | + cd ./python + flake8 ./ + - name: Lint with MyPy + run: | + cd ./python + mypy ./ + - name: Test with unittest + run: | + cd ./python + python -m unittest diff --git a/README.md b/README.md new file mode 100644 index 00000000..714ee322 --- /dev/null +++ b/README.md @@ -0,0 +1,30 @@ +# Репозиторий для работ по курсу информатика + +Вот сюда нужно будет в первой работе с гитом добавит свое ФИО + +## ФИО + +## Работа с репозиторием + +В репозитории присутствуют 2 каталога - для рабработчиков на python и golang. + +Необходимо выбрать ваш стек и в соответствующем каталоге открыть файл проекта `informatics.code-workspace` через vscode. +Для тех, кто использует другие среды разработки - пишите в чат, попробуем помочь настроить. Дальнейшие инструкции для каждого +соответствующего проекта находятся в соответствующем `README.md` файле проекта. + +## Примеры работы с markdown + +Обычный текст. +Еще текст на той же строке (в том же абзаце). + +Текст в новом абзаце + +## Подзаголовок + +``` +Блок кода +``` + +```python +print("Hello world") +``` diff --git a/golang/.golangci.yml b/golang/.golangci.yml new file mode 100644 index 00000000..e6ddb635 --- /dev/null +++ b/golang/.golangci.yml @@ -0,0 +1,111 @@ +run: + tests: false + skip-files: + - \.pb\.go$ + - \.pb\.validate\.go$ + - \.pb\.gw\.go$ + +linters-settings: + dupl: + threshold: 500 + # commented linter rules should be uncommented when corresponding linter will be enabled + # funlen: + # lines: 160 + # statements: 60 + gci: + local-prefixes: github.com/golangci/golangci-lint + # revive: + # min-confidence: 0 + # gomnd: + # checks: + # - argument + # - case + # - condition + # - return + lll: + line-length: 160 + +linters: + # please, do not use `enable-all`: it's deprecated and will be removed soon. + # inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint + # Disabled linters should be enabled later + disable-all: true + enable: + - asciicheck + - bidichk + - bodyclose + - containedctx + # - deadcode + - decorder + - depguard + - dogsled + - dupl + - durationcheck + # - errcheck + - errchkjson + # - errname + - errorlint + - execinquery + - exportloopref + # - forbidigo + - forcetypeassert + # - funlen + - gocognit + - goconst + # - gocritic + - gocyclo + # - gofmt + # - gofumpt + - goheader + # - goimports + # - gomnd + - gomodguard + - goprintffuncname + - gosec + - gosimple + - govet + - grouper + # - ifshort + - importas + - ineffassign + - lll + # - maintidx + - makezero + # - misspell + - nakedret + - nestif + - nilerr + - nilnil + - noctx + # - nolintlint + - nosprintfhostport + - paralleltest + # - prealloc + # - predeclared + - promlinter + # - revive + - rowserrcheck + - sqlclosecheck + # - structcheck + # - stylecheck + # - tagliatelle + - tenv + - testpackage + - tparallel + - typecheck + - unconvert + - unparam + - unused + # - varcheck + - wastedassign + - whitespace + +issues: + # Excluding configuration per-path, per-linter, per-text and per-source + exclude-rules: + - path: _test\.go + linters: + - gomnd + - text: "File is not `goimports`-ed with -local github.com/golangci/golangci-lint" + linters: + - goimports diff --git a/golang/.vscode/launch.json b/golang/.vscode/launch.json new file mode 100644 index 00000000..2e425008 --- /dev/null +++ b/golang/.vscode/launch.json @@ -0,0 +1,18 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Launch Package", + "type": "go", + "request": "launch", + "mode": "auto", + "program": "${fileDirname}", + "console": "integratedTerminal", + "args": ["sample"], + "showLog": true + } + ] +} \ No newline at end of file diff --git a/golang/.vscode/settings.json b/golang/.vscode/settings.json new file mode 100644 index 00000000..6e380ce5 --- /dev/null +++ b/golang/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "go.lintTool": "golangci-lint", + "go.lintFlags": ["--fast"] +} diff --git a/golang/README.md b/golang/README.md new file mode 100644 index 00000000..24dd6987 --- /dev/null +++ b/golang/README.md @@ -0,0 +1,34 @@ +# Работа с проектом + +`vscode` при старте предложит установить рекомендованныек расширения - с ним лучше согласиться. + + +## Настройка окружения + +### Golang + +Установите `golang` для соответствующей операционной системы. + +Запустите выкачивание зависимостей + +```shell +go mod tidy +``` + +Для локальной проверки линтером следует установить линтер. Устанавливать следует из git bash терминала в случае `windows` + +```shell +# binary will be $(go env GOPATH)/bin/golangci-lint +curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.50.1 +``` + +Для запуска линтера следует выполнить следующую команду +```shell +$(go env GOPATH)/bin/golangci-lint run -vvv --out-format tab --print-resources-usage --timeout=180s --config=.golangci.yml +``` + +### Запуск тестов + +```shell +go test -count=1 -p 1 -v ./... +``` \ No newline at end of file diff --git a/golang/go.mod b/golang/go.mod new file mode 100644 index 00000000..d1cc943c --- /dev/null +++ b/golang/go.mod @@ -0,0 +1,5 @@ +module isuct.ru/informatics2022 + +go 1.16 + +require github.com/stretchr/testify v1.8.1 diff --git a/golang/go.sum b/golang/go.sum new file mode 100644 index 00000000..2ec90f70 --- /dev/null +++ b/golang/go.sum @@ -0,0 +1,17 @@ +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/golang/informatics.code-workspace b/golang/informatics.code-workspace new file mode 100644 index 00000000..ec166d2d --- /dev/null +++ b/golang/informatics.code-workspace @@ -0,0 +1,18 @@ +{ + "folders": [ + { + "path": "." + }, + ], + "settings": { + "files.exclude": { + "**/.git": true, + }, + }, + "extensions": { + "recommendations": [ + "golang.go", + "eamodio.gitlens" + ] + } +} diff --git a/golang/internal/sample.go b/golang/internal/sample.go new file mode 100644 index 00000000..c4b72b52 --- /dev/null +++ b/golang/internal/sample.go @@ -0,0 +1,5 @@ +package internal + +func Summ(a, b int) int { + return a + b +} diff --git a/golang/main.go b/golang/main.go new file mode 100644 index 00000000..d2c4e91e --- /dev/null +++ b/golang/main.go @@ -0,0 +1,7 @@ +package main + +import "fmt" + +func main() { + fmt.Println("Hello world") +} diff --git a/golang/tests/sample_test.go b/golang/tests/sample_test.go new file mode 100644 index 00000000..e4f2c320 --- /dev/null +++ b/golang/tests/sample_test.go @@ -0,0 +1,14 @@ +package internal_test + +import ( + "testing" + + "isuct.ru/informatics2022/internal" +) + +func TestSumm(t *testing.T) { + summ := internal.Summ(2, 3) + if summ != 5 { + t.Fatalf(`Summ(2,3) = %d, want 5, error`, summ) + } +} diff --git a/python/.flake8 b/python/.flake8 new file mode 100644 index 00000000..4b473c63 --- /dev/null +++ b/python/.flake8 @@ -0,0 +1,3 @@ +[flake8] +ignore = E722 +max-line-length = 128 diff --git a/python/.gitignore b/python/.gitignore new file mode 100644 index 00000000..c792544c --- /dev/null +++ b/python/.gitignore @@ -0,0 +1,206 @@ +# Prerequisites +*.d + +# Object files +*.o +*.ko +*.obj +*.elf + +# Linker output +*.ilk +*.map +*.exp + +# Precompiled Headers +*.gch +*.pch + +# Libraries +*.lib +*.a +*.la +*.lo + +# Shared objects (inc. Windows DLLs) +*.dll +*.so +*.so.* +*.dylib + +# Executables +*.exe +*.out +*.app +*.i*86 +*.x86_64 +*.hex + +# Debug files +*.dSYM/ +*.su +*.idb +*.pdb + +# Kernel Module Compile Results +*.mod* +*.cmd +.tmp_versions/ +modules.order +Module.symvers +Mkfile.old +dkms.conf +*.out + +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintainted in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ \ No newline at end of file diff --git a/python/.vscode/launch.json b/python/.vscode/launch.json new file mode 100644 index 00000000..0a5c8097 --- /dev/null +++ b/python/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Python: Текущий файл", + "type": "python", + "request": "launch", + "program": "${file}", + "console": "integratedTerminal" + } + ] +} diff --git a/python/.vscode/settings.json b/python/.vscode/settings.json new file mode 100644 index 00000000..2597cbc4 --- /dev/null +++ b/python/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "python.linting.pylintEnabled": false, + "python.linting.mypyEnabled": false, + "python.linting.enabled": true, + "python.linting.lintOnSave": true, + "python.linting.flake8Enabled": true, +} diff --git a/python/Pipfile b/python/Pipfile new file mode 100644 index 00000000..0f6a6f34 --- /dev/null +++ b/python/Pipfile @@ -0,0 +1,19 @@ +[[source]] +url = "https://pypi.org/simple" +verify_ssl = true +name = "pypi" + +[packages] + +[dev-packages] +mypy = "*" +flake8 = "*" + +[requires] +python_version = "3.9" + +[scripts] +start = "python ./src/main.py" +test = "python -m unittest" +lint = "flake8 ./" +lintMyPy = "mypy ./" diff --git a/python/Pipfile.lock b/python/Pipfile.lock new file mode 100644 index 00000000..f3145ef9 --- /dev/null +++ b/python/Pipfile.lock @@ -0,0 +1,106 @@ +{ + "_meta": { + "hash": { + "sha256": "4894b22932cc8c76e138c68198ce54cb057a7f4b391476c15e3e05d193ceb7f7" + }, + "pipfile-spec": 6, + "requires": { + "python_version": "3.9" + }, + "sources": [ + { + "name": "pypi", + "url": "https://pypi.org/simple", + "verify_ssl": true + } + ] + }, + "default": {}, + "develop": { + "flake8": { + "hashes": [ + "sha256:6fbe320aad8d6b95cec8b8e47bc933004678dc63095be98528b7bdd2a9f510db", + "sha256:7a1cf6b73744f5806ab95e526f6f0d8c01c66d7bbe349562d22dfca20610b248" + ], + "index": "pypi", + "version": "==5.0.4" + }, + "mccabe": { + "hashes": [ + "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325", + "sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e" + ], + "markers": "python_version >= '3.6'", + "version": "==0.7.0" + }, + "mypy": { + "hashes": [ + "sha256:1021c241e8b6e1ca5a47e4d52601274ac078a89845cfde66c6d5f769819ffa1d", + "sha256:14d53cdd4cf93765aa747a7399f0961a365bcddf7855d9cef6306fa41de01c24", + "sha256:175f292f649a3af7082fe36620369ffc4661a71005aa9f8297ea473df5772046", + "sha256:26ae64555d480ad4b32a267d10cab7aec92ff44de35a7cd95b2b7cb8e64ebe3e", + "sha256:41fd1cf9bc0e1c19b9af13a6580ccb66c381a5ee2cf63ee5ebab747a4badeba3", + "sha256:5085e6f442003fa915aeb0a46d4da58128da69325d8213b4b35cc7054090aed5", + "sha256:58f27ebafe726a8e5ccb58d896451dd9a662a511a3188ff6a8a6a919142ecc20", + "sha256:6389af3e204975d6658de4fb8ac16f58c14e1bacc6142fee86d1b5b26aa52bda", + "sha256:724d36be56444f569c20a629d1d4ee0cb0ad666078d59bb84f8f887952511ca1", + "sha256:75838c649290d83a2b83a88288c1eb60fe7a05b36d46cbea9d22efc790002146", + "sha256:7b35ce03a289480d6544aac85fa3674f493f323d80ea7226410ed065cd46f206", + "sha256:85f7a343542dc8b1ed0a888cdd34dca56462654ef23aa673907305b260b3d746", + "sha256:86ebe67adf4d021b28c3f547da6aa2cce660b57f0432617af2cca932d4d378a6", + "sha256:8ee8c2472e96beb1045e9081de8e92f295b89ac10c4109afdf3a23ad6e644f3e", + "sha256:91781eff1f3f2607519c8b0e8518aad8498af1419e8442d5d0afb108059881fc", + "sha256:a692a8e7d07abe5f4b2dd32d731812a0175626a90a223d4b58f10f458747dd8a", + "sha256:a705a93670c8b74769496280d2fe6cd59961506c64f329bb179970ff1d24f9f8", + "sha256:c6e564f035d25c99fd2b863e13049744d96bd1947e3d3d2f16f5828864506763", + "sha256:cebca7fd333f90b61b3ef7f217ff75ce2e287482206ef4a8b18f32b49927b1a2", + "sha256:d6af646bd46f10d53834a8e8983e130e47d8ab2d4b7a97363e35b24e1d588947", + "sha256:e7aeaa763c7ab86d5b66ff27f68493d672e44c8099af636d433a7f3fa5596d40", + "sha256:eaa97b9ddd1dd9901a22a879491dbb951b5dec75c3b90032e2baa7336777363b", + "sha256:eb7a068e503be3543c4bd329c994103874fa543c1727ba5288393c21d912d795", + "sha256:f793e3dd95e166b66d50e7b63e69e58e88643d80a3dcc3bcd81368e0478b089c" + ], + "index": "pypi", + "version": "==0.982" + }, + "mypy-extensions": { + "hashes": [ + "sha256:090fedd75945a69ae91ce1303b5824f428daf5a028d2f6ab8a299250a846f15d", + "sha256:2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8" + ], + "version": "==0.4.3" + }, + "pycodestyle": { + "hashes": [ + "sha256:2c9607871d58c76354b697b42f5d57e1ada7d261c261efac224b664affdc5785", + "sha256:d1735fc58b418fd7c5f658d28d943854f8a849b01a5d0a1e6f3f3fdd0166804b" + ], + "markers": "python_version >= '3.6'", + "version": "==2.9.1" + }, + "pyflakes": { + "hashes": [ + "sha256:4579f67d887f804e67edb544428f264b7b24f435b263c4614f384135cea553d2", + "sha256:491feb020dca48ccc562a8c0cbe8df07ee13078df59813b83959cbdada312ea3" + ], + "markers": "python_version >= '3.6'", + "version": "==2.5.0" + }, + "tomli": { + "hashes": [ + "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc", + "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f" + ], + "markers": "python_version < '3.11'", + "version": "==2.0.1" + }, + "typing-extensions": { + "hashes": [ + "sha256:1511434bb92bf8dd198c12b1cc812e800d4181cfcb867674e0f8279cc93087aa", + "sha256:16fa4864408f655d35ec496218b85f79b3437c829e93320c7c9215ccfd92489e" + ], + "markers": "python_version >= '3.7'", + "version": "==4.4.0" + } + } +} diff --git a/python/README.md b/python/README.md new file mode 100644 index 00000000..a3948147 --- /dev/null +++ b/python/README.md @@ -0,0 +1,54 @@ +# Работа с проектом + +`vscode` при старте предложит установить рекомендованныек расширения - с ним лучше согласиться. + + +## Настройка окружения + +### Python + +Установите `python` для соответствующей операционной системы. + +**ВАЖНО** + +При установке в windows - укажите галочку - добавить python в переменную окружения `PATH` + +### Pipenv + +Мы используем виртуальное окружение `pipenv`, для его установки используйте следующую команду: + +```shell +pip install pipenv +``` +Установку требуется сделать только 1 раз, активацию - каждый раз когда вы перезапускаете терминал. + + +Для активации виртуального окружения следует выполнить следующую команду, при этом выполнять ее нужно в каталоге текущего проекта `python` (рядом с текущим `README.md` файлом и содержит `Pipfile`) + +``` +pipenv shell +``` + +После этого необходимо установить зависимости, указанные в `pipenv` файле + + + +После установки pipenv при использовании `vscode` следует выбрать версию интерпретатора, привязанный к проекту. Для этого можно выполнить следующую последовательность действий. Настраивать требуется только 1 раз при настройке виртуального окружения. + +- Нажать комбинацию клавиш `ctrl-shift-p` +- Начать писать `Reload window` +- Начать писать `Python select interpreter` +- Выбрать на уровне рабочей области +- Найти свое окружение, скорее всего в его имени в скобках будет указано `(python-"НАБОР_СИМВОЛОВ")` + +Ваше рабочее окружение настроено и можете его иcпользовать. + +### Доступные команды + +Команды проверок, запускаемые в `github actions` можно также запустить локально выполнением одной из следующих команд + +```shell +pipenv run test +pipenv run lint +pipenv run lintMyPy +``` \ No newline at end of file diff --git a/python/informatics.code-workspace b/python/informatics.code-workspace new file mode 100644 index 00000000..9c3d46e1 --- /dev/null +++ b/python/informatics.code-workspace @@ -0,0 +1,19 @@ +{ + "folders": [ + { + "path": "." + }, + ], + "settings": { + "files.exclude": { + "**/.git": true, + }, + "editor.tabSize": 4, + }, + "extensions": { + "recommendations": [ + "ms-python.python", + "eamodio.gitlens" + ] + } +} diff --git a/python/requirements.txt b/python/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..35e3f5c93487906e74f1a63511caba4138a95f2c GIT binary patch literal 646 zcmZuv+irqT5S(X|ehNlVQ+?>S7z8v_j-DV%wIAO)v&-?47_#y(mz^E_|0{9EfF38b zsPV<8z!drY_X87DL_1E85`iPujI0G`2{CG_J3a}S8zLW}J0c|xXs|NIlBny2woD-J z;g02ox>m|xT#=Ep#Wy`FGBZTWd?BKpIUPSat_kE+)NRR5iGFT-hqun*|KIISALO(LqqV9BO?Nf_2J=OP>O3x{ zlar?xqhqGy*q47TZSpTMa7!?T@(R_B?w+s%_1?B)YA>nPO~afS`%}`?uCDf5ls;O5 XJvQXNZ%TZPr~a}3PJHsq4fR|%QM+D> literal 0 HcmV?d00001 diff --git a/python/src/__init__.py b/python/src/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/python/src/main.py b/python/src/main.py new file mode 100644 index 00000000..e37a77c0 --- /dev/null +++ b/python/src/main.py @@ -0,0 +1,7 @@ +def summ(a: int, b: int) -> int: + return a + b + + +if __name__ == "__main__": + print("Hello world") + print(summ(3, 4)) diff --git a/python/tests/__init__.py b/python/tests/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/python/tests/test_main.py b/python/tests/test_main.py new file mode 100644 index 00000000..0280a2e7 --- /dev/null +++ b/python/tests/test_main.py @@ -0,0 +1,37 @@ +import unittest +from src import main + + +class SummTests(unittest.TestCase): + + def test_positive(self): + res = main.summ(2, 3) + self.assertEqual(5, res) + + def test_zero(self): + res = main.summ(0, 0) + self.assertEqual(0, res) + + def test_one_negative(self): + res = main.summ(-2, 3) + self.assertEqual(1, res) + + def test_both_negative(self): + res = main.summ(-2, -4) + self.assertEqual(-6, res) + + def test_one_negative_zero_res(self): + res = main.summ(-2, 2) + self.assertEqual(0, res) + + def test_one_negative_and_text(self): + try: + main.summ(-2, "2") + except: + self.assertTrue(True) + return + self.fail() + + +if __name__ == '__main__': + unittest.main()