dash/.gitignore
fanquake 271acac3a7
Merge #18210: test: type hints in Python tests
bd7e530f010d43816bb05d6f1590d1cd36cdaa2c This PR adds initial support for type hints checking in python scripts. (Kiminuo)

Pull request description:

  This PR adds initial support for type hints checking in python scripts.

  Support for type hints was introduced in Python 3.5. Type hints make it easier to read and review code in my opinion. Also an IDE may discover a potential bug sooner. Yet, as PEP 484 says: "It should also be emphasized that Python will remain a dynamically typed language, and the authors have no desire to ever make type hints mandatory, even by convention."

  [Mypy](https://mypy.readthedocs.io/en/latest/index.html) is used in `lint-python.sh` to do the type checking. The package is standard so there is little chance that it will be abandoned. Mypy checks that type hints in source code are correct when they are not, it fails with an error.

  **Notes:**

  * [--ignore-missing-imports](https://mypy.readthedocs.io/en/latest/command_line.html#cmdoption-mypy-ignore-missing-imports) switch is passed on to `mypy` checker for now. The effect of this is that one does not need `# type: ignore` for `import zmq`. More information about import processing can be found [here](https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports). This can be changed in a follow-up PR, if it is deemed useful.
  * We are stuck with Python 3.5 until 04/2021 (see https://packages.ubuntu.com/xenial/python3). When Python version is bumped to 3.6+, one can change:
      ```python
      _opcode_instances = []  # type: List[CScriptOp]
      ```
      to
      ```python
      _opcode_instances:List[CScriptOp] = []
      ```
      for type hints that are **not** function parameters and function return types.

  **Useful resources:**

  * https://docs.python.org/3.5/library/typing.html
  * https://www.python.org/dev/peps/pep-0484/

ACKs for top commit:
  fanquake:
    ACK bd7e530f010d43816bb05d6f1590d1cd36cdaa2c - the type checking is not the most robust (there are things it fails to detect), but I think this is worth adopting (in a limited capacity while we maintain 3.5 compat).
  MarcoFalke:
    ACK bd7e530f010d43816bb05d6f1590d1cd36cdaa2c fine with me

Tree-SHA512: 21ef213915fb1dec6012f59ef17484e6c9e0abf542a316b63d5f21a7778ad5ebabf8961ef5fc8e5414726c2ee9c6ae07c7353fb4dd337f8fcef5791199c8987a
2024-01-10 12:07:54 -06:00

170 lines
2.0 KiB
Plaintext

*.sublime-project
*.sublime-workspace
todo.txt
reset-files.bash
*.tar.gz
*.exe
src/dash
src/dashd
src/dash-cli
src/dash-tx
src/dash-wallet
src/test/fuzz/*
!src/test/fuzz/*.*
src/test/test_dash
src/qt/test/test_dash-qt
src/qt/res/css/colors/*
src/bench/bench_dash
# autoreconf
Makefile.in
aclocal.m4
autom4te.cache/
build-aux/config.guess
build-aux/config.sub
build-aux/depcomp
build-aux/install-sh
build-aux/ltmain.sh
build-aux/m4/libtool.m4
build-aux/m4/lt~obsolete.m4
build-aux/m4/ltoptions.m4
build-aux/m4/ltsugar.m4
build-aux/m4/ltversion.m4
build-aux/missing
build-aux/compile
build-aux/test-driver
config.cache
config.log
config.status
configure
libtool
src/config/bitcoin-config.h
src/config/bitcoin-config.h.in
src/config/stamp-h1
src/obj
share/setup.nsi
share/qt/Info.plist
src/univalue/gen
src/qt/*.moc
src/qt/moc_*.cpp
src/qt/forms/ui_*.h
src/qt/test/moc*.cpp
libconftest.dylib*
.deps
.dirstamp
.libs
.*.swp
*~
*.bak
*.rej
*.orig
*.pyc
*.o
*.o-*
*.a
*.pb.cc
*.pb.h
*.dat
*.log
*.trs
*.dmg
*.iso
*.json.h
*.raw.h
# Only ignore unexpected patches
*.patch
!contrib/guix/patches/*.patch
!depends/patches/**/*.patch
#libtool object files
*.lo
*.la
# Compilation and Qt preprocessor part
*.qm
Makefile
!depends/Makefile
dash-qt
Dash-Qt.app
# Qt Creator
Makefile.am.user
# Unit-tests
Makefile.test
dash-qt_test
# Resources cpp
qrc_*.cpp
# Mac specific
.DS_Store
build
*.dSYM
# Previous releases
releases
#lcov
*.gcno
*.gcda
/*.info
test_dash.coverage/
total.coverage/
coverage_percent.txt
#build tests
linux-coverage-build
linux-build
win32-build
test/config.ini
test/cache/*
test/.mypy_cache/
!src/leveldb*/Makefile
.cproject
.project
.autotools
/doc/doxygen/
libdashconsensus.pc
contrib/devtools/split-debug.sh
src/qt/dash-qt.bash
qa/pull-tester/tests-config.sh
#development symlinks
dash-cli
dashd
dash-qt
make
/docker/bin
# CLion
.idea
cmake-build-debug
# clang-check
*.plist
osx_volname
dist/
/guix-build-*
# cppcheck cache-directory
test/lint/.cppcheck/*
# flake8 cache location
.cache/*