Skip to content

A Python package to check if an object is of a certain type in an instant.

License

Notifications You must be signed in to change notification settings

joaopalmeiro/istant

Repository files navigation

istant

security: bandit Code style: black

A Python package to check if an object is of a certain type in an instant.

Development

  • poetry install
  • poetry shell
  • pytest

Tech Stack

Packaging and Development

This package was created with Cookiecutter and the joaopalmeiro/cookiecutter-templates/python-pkg project template.

References

Notes

  • pyenv:
  • Vim:
    • Learning tools:
    • Two basic modes:
      • insert mode (i): to write text (like in a text editor).
      • normal mode (Esc): to navigate and manipulate text.
    • Basic movement: h (←), j (↓), k (↑), and l (→).
    • Word movement:
      • w: start of the next word.
      • e: end of the word.
      • b: beginning of the word.
      • These keys can be combined with a number (number powered movement). 3w is the same as pressing w 3x, for example.
    • Insert text repeatedly: 30 + i + - + Esc to insert - 30x, for example.
    • Find a character:
      • f: next occurrence of a character.
      • F: previous occurrence of a character.
      • fo to find the next o, for example.
      • These keys can also be combined with numbers.
    • Go to matching parentheses: %.
    • Go to start/end of line: 0/$.
    • Find word under cursor:
      • *: next occurrence.
      • #: previous occurrence.
    • Go to beginning/end of file: gg/G. G can be combined with a number too.
    • Search:
      • /<text>.
      • n: next occurrence.
      • N: previous occurrence.
    • Insert new line:
      • o: below the current line.
      • O: above the current line.
      • The editor is set to insert mode.
    • Remove a character:
      • x: under the cursor.
      • X: to the left of the cursor.
    • Replace a character:
      • r.
      • Under the cursor, without switching to insert mode.
    • Delete:
      • d.
      • It can be combined with numbers and movement keys (dw and d2e, for example).
      • It copies the content. Content can be pasted with p.
    • Repeat the previous command: ..
    • Visual mode:
      • v.
      • To select text with the movement keys first and then apply a command.
    • Exiting:
      • :w: save.
      • :q: quit.
      • :q!: quit without saving.
    • Editing:
      • u: undo.
      • Ctrl + r: redo.
    • Vim.gitignore file.

VIM and Python – A Match Made in Heaven

Source.

  • .vimrc file.
  • vim --version.
  • *nix or Unix-like systems.
  • Check the Python version used in Vim: :python import sys; print(sys.version).
  • Extensions or bundles or plugins.
  • Vundle:
    • pip for Vim/Vim plugin manager.
    • git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim.
    • Extensions can be managed from the .vimrc file (touch ~/.vimrc) + :PluginInstall.
  • Split layouts:
    • :sp <filename>: vertical split.
    • :vs <filename>: horizontal split.
  • vscode-viml-syntax (VS Code extension).
  • Buffers:
    • Think of a buffer as a recently opened file.
    • :b <buffer name or number>: switch to an open buffer.
    • :ls: list all buffers.
  • Extensions:

Effective Python Testing With Pytest

Source.

  • poetry add -D pytest.
  • Arrange (set up)-Act-Assert model.
  • pytest allows you to use Python's assert directly.
  • Test double: an object that stands in for another object during a test (source), such as mocks, for example.
  • Fixtures (@pytest.fixture decorator + conftest.py file):
    • Functions that create data/test doubles or initialize some system state for the test suite.
    • They are appropriate to be used across multiple tests.
    • They are used as arguments (explicit dependency declarations).
    • They are modular, so they can depend on other fixtures.
  • Test filtering:
    • Name-based filtering (-k).
    • Directory scoping.
    • Test categorization (-m <name> or -m "not <name>"). pytest allows you to create marks (custom labels) for any test.
  • Test parameterization.
  • Plugin-based architecture.
  • monkeypatch fixture (+ @pytest.fixture(autouse=True) in the conftest.py file): to safely patch and mock functionality in tests, allowing to set/delete an attribute, dictionary item, or environment variable, for example (requests.get(), for example).
  • Marks (@pytest.mark.<name>):
    • It is possible to register marks in the pytest.ini file (or in the pyproject.toml file). This can be combined with the --strict-markers flag to ensure that all marks in the tests are registered in the pytest configuration. On the other hand, addopts = --strict-markers can be added to the pytest.ini file.
    • Run pytest --markers to check the list of marks.
    • skip: to skip a test.
    • skipif: to skip a test if the expression passed to it evaluates to True.
    • xfail: a test is expected to fail.
    • parametrize. The first argument is a comma-delimited string of parameter names. The second argument is a list of either tuples or single values.
  • --durations flag:
    • To include a duration report in the results.
    • --durations=3 to report the slowest 3 tests, for example.
  • Plugins:

About

A Python package to check if an object is of a certain type in an instant.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published