From 10c7bc6161ba0229a007d74114a77e45cac4c6e6 Mon Sep 17 00:00:00 2001
From: YariKartoshe4ka <49284924+YariKartoshe4ka@users.noreply.github.com>
Date: Thu, 2 Jun 2022 12:10:06 +0300
Subject: [PATCH] Modernize layout (#124)
* Upgrading layout: creating pyproject.toml, moving vk to src dir, skipping non-working tests, configuring tox and other
* Fixing coverage missing
* Adding pre-commit hook
* Fix sphinx build
* Remove make files from docs
* Adding docs env to tox for docs building
* Update README.md
* Setup autorelease on PyPI
* Adding URLs to pyproject.toml
---
.editorconfig | 14 --
.github/workflows/check.yml | 86 ++++++++++++
.gitignore | 23 +---
.pre-commit-config.yaml | 27 ++++
.travis.yml | 41 ------
Pipfile | 33 -----
README.md | 42 +++---
Vagrantfile | 51 -------
docs/Makefile | 183 --------------------------
docs/conf.py | 146 ++-------------------
docs/customizing.rst | 6 +-
docs/how-it-works.rst | 24 ----
docs/make.bat | 248 -----------------------------------
docs/usage.rst | 26 +---
pyproject.toml | 57 ++++++++
setup.cfg | 72 ----------
setup.py | 12 --
src/vk/__init__.py | 5 +
{vk => src/vk}/api.py | 0
{vk => src/vk}/exceptions.py | 0
{vk => src/vk}/session.py | 4 +-
{vk => src/vk}/utils.py | 2 +-
tests/conftest.py | 13 +-
tests/test_api.py | 10 +-
tests/test_api_namespace.py | 6 +-
tests/test_user_api.py | 14 +-
tox.ini | 37 ++++++
vagrant-provision.sh | 16 ---
vk/__init__.py | 5 -
29 files changed, 275 insertions(+), 928 deletions(-)
delete mode 100644 .editorconfig
create mode 100644 .github/workflows/check.yml
create mode 100644 .pre-commit-config.yaml
delete mode 100644 .travis.yml
delete mode 100644 Pipfile
delete mode 100644 Vagrantfile
delete mode 100644 docs/Makefile
delete mode 100644 docs/how-it-works.rst
delete mode 100644 docs/make.bat
create mode 100644 pyproject.toml
delete mode 100644 setup.cfg
delete mode 100644 setup.py
create mode 100644 src/vk/__init__.py
rename {vk => src/vk}/api.py (100%)
rename {vk => src/vk}/exceptions.py (100%)
rename {vk => src/vk}/session.py (99%)
rename {vk => src/vk}/utils.py (97%)
create mode 100644 tox.ini
delete mode 100644 vagrant-provision.sh
delete mode 100644 vk/__init__.py
diff --git a/.editorconfig b/.editorconfig
deleted file mode 100644
index 02aa871..0000000
--- a/.editorconfig
+++ /dev/null
@@ -1,14 +0,0 @@
-root = true
-
-[*]
-indent_size = 4
-indent_style = space
-end_of_line = lf
-insert_final_newline = true
-trim_trailing_whitespace = true
-
-[*.py]
-max_line_length = 120
-
-[*.md]
-trim_trailing_whitespace = false
diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml
new file mode 100644
index 0000000..c892dde
--- /dev/null
+++ b/.github/workflows/check.yml
@@ -0,0 +1,86 @@
+name: Check
+
+on:
+ pull_request:
+ push:
+
+ schedule:
+ - cron: "0 12 * * *"
+
+jobs:
+ test:
+ name: Run tests - Python ${{ matrix.py }}
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ py:
+ - "3.7"
+ - "3.8"
+ - "3.9"
+ - "3.10"
+ - "pypy-3.7"
+ - "pypy-3.8"
+ steps:
+ - name: Setup Python for tox
+ uses: actions/setup-python@v2
+ with:
+ python-version: "3.8"
+ - name: Install tox
+ run: pip install tox
+ - name: Setup Python ${{ matrix.py }} for test
+ uses: actions/setup-python@v2
+ with:
+ python-version: ${{ matrix.py }}
+ - name: Checkout code
+ uses: actions/checkout@v2
+ - name: Setup test suite
+ run: tox -vv --notest
+ - name: Run test suite
+ run: tox --skip-pkg-install
+ - name: Upload coverage
+ uses: codecov/codecov-action@v2
+
+ check:
+ name: Check - Tox ${{ matrix.tox_env }}
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ tox_env:
+ - fix
+ - docs
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v2
+ - name: Setup Python for tox
+ uses: actions/setup-python@v2
+ with:
+ python-version: "3.8"
+ - name: Install tox
+ run: pip install tox
+ - name: Setup test suite
+ run: tox -vv --notest -e ${{ matrix.tox_env }}
+ - name: Run test suite
+ run: tox --skip-pkg-install -e ${{ matrix.tox_env }}
+
+ publish:
+ name: Publish on PyPI
+ if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
+ needs: [ test, check ]
+ runs-on: ubuntu-latest
+ steps:
+ - name: Setup Python
+ uses: actions/setup-python@v2
+ with:
+ python-version: "3.8"
+ - name: Install dependencies
+ run: pip install build
+ - name: Checkout code
+ uses: actions/checkout@v2
+ - name: Build project
+ run: python -m build --sdist --wheel --outdir dist/ .
+ - name: Publish on PyPI
+ uses: pypa/gh-action-pypi-publish@master
+ with:
+ password: ${{ secrets.PYPI_API_TOKEN }}
diff --git a/.gitignore b/.gitignore
index 6faf906..3a01cea 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,31 +3,18 @@ __pycache__/
*.py[cod]
# Distribution / packaging
-/dist/
-/vk.egg-info/
+build/
+dist/
+*.egg-info/
# pipenv
-/.env
-/Pipfile.lock
+/venv/
# Unit test / coverage reports
/.coverage
+/coverage.xml
/.pytest_cache/
/.tox/
-# Mr Developer
-.mr.developer.cfg
-.project
-.pydevproject
-
-# Rope
-.ropeproject
-
-# Sphinx documentation
-/docs/_build/
-
# IDEs
/.idea/
-
-# Vagrant
-/.vagrant/
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
new file mode 100644
index 0000000..8d06af0
--- /dev/null
+++ b/.pre-commit-config.yaml
@@ -0,0 +1,27 @@
+repos:
+ - repo: https://github.com/pre-commit/pre-commit-hooks
+ rev: v4.2.0
+ hooks:
+ - id: check-builtin-literals
+ - id: check-docstring-first
+ - id: check-merge-conflict
+ - id: check-yaml
+ - id: check-toml
+ - id: end-of-file-fixer
+ - id: trailing-whitespace
+
+ - repo: https://github.com/PyCQA/isort
+ rev: 5.10.1
+ hooks:
+ - id: isort
+
+ - repo: https://github.com/PyCQA/flake8
+ rev: 4.0.1
+ hooks:
+ - id: flake8
+ additional_dependencies:
+ - flake8-bugbear
+ - flake8-comprehensions
+ - flake8-unused-arguments
+ - flake8-noqa
+ - pep8-naming
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 911947f..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,41 +0,0 @@
-dist: bionic
-sudo: false
-cache:
- directories:
- - $HOME/.cache/pip
- - $HOME/.cache/pipenv
-
-language: python
-python:
- # First value is default
- - "3.5"
- - "3.6"
- - "pypy3.5"
-
-install:
- - pip install pipenv
- - pipenv install --dev --skip-lock
-
-script:
- - pipenv run fulltest
-
-jobs:
- include:
- - stage: Test
- name: Test docs
- install:
- - pip install pipenv sphinx
- - pipenv install --skip-lock
- script:
- - pipenv run doctest
- - pipenv run build-docs
-
- - stage: Coverage
- name: codecov
- before_script: pip install codecov
- script:
- - pytest --cov
- - codecov --required
-
-env:
- secure: "ci9SGpJhSCsF3EKNpn0N0LfvCjTDAS/OMn2EIkzyh0d1mwcWX/O56osLsqYqEK+JCUIS+t1E4u99iLSABecTTotqZ8yVwpDaiyLMjwbBYJ2TdmkYvi9bYgyLVmAZ3UZUIwu2pLwTQBWN1a3ng5VQert2xSsxc9E0uNhd7GxkHkbgOMaD17mC7EPIy7e6QfYCskFn8Z+V+FTM9JRkjpnq+KOhDy5f/7H3ePEx3AvoMBW4LSYjIiQFVh+kIIbvvg7EhNdqJIcvdvkQ2M7Eqw2pj2cExB3RyRO6YQf4ie7//enXyRcCHKLTwtx1cBOSOjLqUJhkYBcm4vTBPLs11nz76sGFah+EXCGx9WcCrvUE5Zz5mcP165xpUBFKot8WEAfja+gH+5dH+3v4H86RLPwG4dE/kIz5i8R85dvZRWkKZdcaKfVYuZhij7QFqxbNLmuhyYTdw+J9vyHK7rE2ZthUNeQGgMNGtnQ56fPA5Foy0xseqxRwMvU6m7bTeFEBvXq4afTI+VSlodUYh492v9pV+LHnZ6uNJrJKCMvqLW+LVvrFJUdb0t4qH5aZ94loUtbCnipRR4vYWId5D+NqiVth6EhWypNjJCINtFaOP8NUCMBdbX8RQjZ0W0r++9q07hXvsoEVK3ofjtYnGJfqfanKqS0DmXsgH8LKyPvd75zoc9U="
diff --git a/Pipfile b/Pipfile
deleted file mode 100644
index 7741e1a..0000000
--- a/Pipfile
+++ /dev/null
@@ -1,33 +0,0 @@
-[[source]]
-url = "https://pypi.python.org/simple"
-name = "pypi"
-verify_ssl = true
-
-[packages]
-requests = "~=2.11"
-
-[dev-packages]
-ipython = "*"
-ipdb = "*"
-pytest = "*"
-pytest-cov = "*"
-pytest-flake8 = "*"
-pytest-pythonpath = "*"
-"flake8-comprehensions" = "~=1.2"
-"flake8-quotes" = "~=0.8"
-"flake8-commas" = "~=0.1"
-"flake8_tuple" = "~=0.2"
-Sphinx = "~=1.4"
-sphinx-autobuild = "~=0.6"
-
-[requires]
-python_version = "3.5"
-
-[scripts]
-test = "pytest --exitfirst --failed-first"
-fulltest = "pytest --flake8 --cov --no-cov-on-fail vk tests docs/conf.py"
-# We use equivalent of "make mode":
-# sphinx-build -M builder . _build
-docs = "sphinx-autobuild --open-browser --port 0 --delay 1 -d docs/_build/doctrees docs docs/_build/html"
-doctest = "sphinx-build -b doctest -d docs/_build/doctrees docs docs/_build/doctest"
-build-docs = "sphinx-build -b html -d docs/_build/doctrees docs docs/_build/html"
diff --git a/README.md b/README.md
index 7b482e8..cbf91fa 100644
--- a/README.md
+++ b/README.md
@@ -1,39 +1,37 @@
-Python vk.com API wrapper
-=========================
+# vk | python vk.com API wrapper
-[![PyPI](https://img.shields.io/pypi/pyversions/vk.svg)](https://pypi.org/project/vk/ "Latest version on PyPI")
-[![Travis](https://travis-ci.com/voronind/vk.svg?branch=master)](https://travis-ci.com/voronind/vk "Travis CI")
-[![Docs](https://readthedocs.org/projects/vk/badge/?version=stable)](https://vk.readthedocs.io/en/latest/ "Read the docs")
-[![codecov](https://codecov.io/gh/voronind/vk/branch/master/graph/badge.svg)](https://codecov.io/gh/voronind/vk "Coverage")
+[![Maintanance](https://img.shields.io/maintenance/yes/2022?style=flat-square)](https://github.com/voronind/vk/commits/master)
+[![PyPI](https://img.shields.io/pypi/pyversions/vk?style=flat-square)](https://pypi.org/project/vk/)
+[![GitHub CI](https://img.shields.io/github/workflow/status/voronind/vk/Check/master?style=flat-square)](https://github.com/voronind/vk/actions)
+[![Codecov](https://img.shields.io/codecov/c/github/voronind/vk?style=flat-square)](https://codecov.io/gh/voronind/vk)
+[![Docs](https://img.shields.io/readthedocs/vk?style=flat-square)](https://vk.readthedocs.io/en/latest/)
-This is a vk.com (the largest Russian social network)
-python API wrapper. The goal is to support all API methods (current and future)
-that can be accessed from server.
+This is a vk.com (the largest Russian social network) python API wrapper.
+The goal is to support all API methods (current and future) that can be accessed from server.
-Quickstart
-==========
-Install
--------
+## Quickstart
-```console
+
+### Install
+
+```bash
pip install vk
```
-Usage
------
+
+### Usage
```python
>>> import vk
->>> session = vk.Session()
->>> api = vk.API(session)
+>>> api = vk.API(access_token='...')
>>> api.users.get(user_ids=1)
[{'first_name': 'Pavel', 'last_name': 'Durov', 'id': 1}]
```
-See https://vk.com/dev/methods for detailed API guide.
+See official VK [documentation](https://dev.vk.com/method) for detailed API guide.
+
-More info
-=========
+## More info
-Read full documentation https://vk.readthedocs.org
+Read full documentation on [Read the Docs](https://vk.readthedocs.org)
diff --git a/Vagrantfile b/Vagrantfile
deleted file mode 100644
index 5381e59..0000000
--- a/Vagrantfile
+++ /dev/null
@@ -1,51 +0,0 @@
-# -*- mode: ruby -*-
-# vi: set ft=ruby :
-
-# All Vagrant configuration is done below. The "2" in Vagrant.configure
-# configures the configuration version (we support older styles for
-# backwards compatibility). Please don't change it unless you know what
-# you're doing.
-Vagrant.configure(2) do |config|
- # Every Vagrant development environment requires a box. You can search for
- # boxes at https://atlas.hashicorp.com/search
- config.vm.box = "ubuntu/xenial64"
- config.vm.define "vk" do |vk|
- end
-
- # Create a private network, which allows host-only access to the machine
- # using a specific IP.
- # config.vm.network "private_network", ip: "192.168.33.10"
-
- # Create a public network, which generally matched to bridged network.
- # Bridged networks make the machine appear as another physical device on your network.
- #config.vm.network "public_network", :netmask => "255.0.0.0"
-
- # Share an additional folder to the guest VM. The first argument is
- # the path on the host to the actual folder. The second argument is
- # the path on the guest to mount the folder. And the optional third
- # argument is a set of non-required options.
- config.vm.synced_folder ".", "/vagrant", disabled: true
- config.vm.synced_folder ".", "/home/ubuntu/vk/", create: true, disabled: false
-
- # Provider-specific configuration so you can fine-tune various
- # backing providers for Vagrant. These expose provider-specific options.
- # Example for VirtualBox:
- #
- config.vm.provider "virtualbox" do |v|
- v.name = "vk"
-
- # Display the VirtualBox GUI when booting the machine
- v.gui = false
-
- # Customize the amount of memory on the VM:
- v.memory = 512
- end
- #
- # View the documentation for the provider you are using for more
- # information on available options.
-
- # Enable provisioning with a shell script. Additional provisioners such as
- # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
- # documentation for more information about their specific syntax and use.
- config.vm.provision "shell", privileged: false, path: "vagrant-provision.sh"
-end
diff --git a/docs/Makefile b/docs/Makefile
deleted file mode 100644
index 916b75b..0000000
--- a/docs/Makefile
+++ /dev/null
@@ -1,183 +0,0 @@
-# Makefile for Sphinx documentation
-#
-
-# You can set these variables from the command line.
-SPHINXOPTS =
-SPHINXBUILD = sphinx-build
-PAPER =
-BUILDDIR = _build
-
-# User-friendly check for sphinx-build
-ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
-$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
-endif
-
-# Internal variables.
-PAPEROPT_a4 = -D latex_paper_size=a4
-PAPEROPT_letter = -D latex_paper_size=letter
-ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
-# the i18n builder cannot share the environment and doctrees with the others
-I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
-
-.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
-
-help:
- @echo "Please use \`make ' where is one of"
- @echo " html to make standalone HTML files"
- @echo " livehtml to run HTTP Server"
- @echo " dirhtml to make HTML files named index.html in directories"
- @echo " singlehtml to make a single large HTML file"
- @echo " pickle to make pickle files"
- @echo " json to make JSON files"
- @echo " htmlhelp to make HTML files and a HTML help project"
- @echo " qthelp to make HTML files and a qthelp project"
- @echo " devhelp to make HTML files and a Devhelp project"
- @echo " epub to make an epub"
- @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
- @echo " latexpdf to make LaTeX files and run them through pdflatex"
- @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
- @echo " text to make text files"
- @echo " man to make manual pages"
- @echo " texinfo to make Texinfo files"
- @echo " info to make Texinfo files and run them through makeinfo"
- @echo " gettext to make PO message catalogs"
- @echo " changes to make an overview of all changed/added/deprecated items"
- @echo " xml to make Docutils-native XML files"
- @echo " pseudoxml to make pseudoxml-XML files for display purposes"
- @echo " linkcheck to check all external links for integrity"
- @echo " doctest to run all doctests embedded in the documentation (if enabled)"
-
-clean:
- rm -rf $(BUILDDIR)/*
-
-html:
- $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
- @echo
- @echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
-
-livehtml:
- sphinx-autobuild -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
- @echo
- @echo "Autobuild started. The HTML pages are in $(BUILDDIR)/html."
-
-dirhtml:
- $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
- @echo
- @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
-
-singlehtml:
- $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
- @echo
- @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
-
-pickle:
- $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
- @echo
- @echo "Build finished; now you can process the pickle files."
-
-json:
- $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
- @echo
- @echo "Build finished; now you can process the JSON files."
-
-htmlhelp:
- $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
- @echo
- @echo "Build finished; now you can run HTML Help Workshop with the" \
- ".hhp project file in $(BUILDDIR)/htmlhelp."
-
-qthelp:
- $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
- @echo
- @echo "Build finished; now you can run "qcollectiongenerator" with the" \
- ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
- @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/Vk.qhcp"
- @echo "To view the help file:"
- @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Vk.qhc"
-
-devhelp:
- $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
- @echo
- @echo "Build finished."
- @echo "To view the help file:"
- @echo "# mkdir -p $$HOME/.local/share/devhelp/Vk"
- @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/Vk"
- @echo "# devhelp"
-
-epub:
- $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
- @echo
- @echo "Build finished. The epub file is in $(BUILDDIR)/epub."
-
-latex:
- $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
- @echo
- @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
- @echo "Run \`make' in that directory to run these through (pdf)latex" \
- "(use \`make latexpdf' here to do that automatically)."
-
-latexpdf:
- $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
- @echo "Running LaTeX files through pdflatex..."
- $(MAKE) -C $(BUILDDIR)/latex all-pdf
- @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
-
-latexpdfja:
- $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
- @echo "Running LaTeX files through platex and dvipdfmx..."
- $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
- @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
-
-text:
- $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
- @echo
- @echo "Build finished. The text files are in $(BUILDDIR)/text."
-
-man:
- $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
- @echo
- @echo "Build finished. The manual pages are in $(BUILDDIR)/man."
-
-texinfo:
- $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
- @echo
- @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
- @echo "Run \`make' in that directory to run these through makeinfo" \
- "(use \`make info' here to do that automatically)."
-
-info:
- $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
- @echo "Running Texinfo files through makeinfo..."
- make -C $(BUILDDIR)/texinfo info
- @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
-
-gettext:
- $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
- @echo
- @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
-
-changes:
- $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
- @echo
- @echo "The overview file is in $(BUILDDIR)/changes."
-
-linkcheck:
- $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
- @echo
- @echo "Link check complete; look for any errors in the above output " \
- "or in $(BUILDDIR)/linkcheck/output.txt."
-
-doctest:
- $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
- @echo "Testing of doctests in the sources finished, look at the " \
- "results in $(BUILDDIR)/doctest/output.txt."
-
-xml:
- $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
- @echo
- @echo "Build finished. The XML files are in $(BUILDDIR)/xml."
-
-pseudoxml:
- $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
- @echo
- @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
diff --git a/docs/conf.py b/docs/conf.py
index 9f0a987..a77d1e4 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -1,157 +1,27 @@
-# -*- coding: utf-8 -*-
-#
-# Configuration file for the Sphinx documentation builder.
-#
-# This file does only contain a selection of the most common options. For a
-# full list see the documentation:
-# http://www.sphinx-doc.org/en/master/config
+from vk import __version__
-# -- Path setup --------------------------------------------------------------
-
-# If extensions (or modules to document with autodoc) are in another directory,
-# add these directories to sys.path here. If the directory is relative to the
-# documentation root, use os.path.abspath to make it absolute, like shown here.
-#
-# import os
-# import sys
-# sys.path.insert(0, os.path.abspath('.'))
-
-
-# -- Project information -----------------------------------------------------
-
-project = 'Vk'
-copyright = '2015, Dmitry Voronin'
author = 'Dmitry Voronin'
-
-# The short X.Y version
-version = ''
-# The full version, including alpha/beta/rc tags
-release = '3.0-dev'
+project = 'vk'
+copyright = '2015, Dmitry Voronin'
-# -- General configuration ---------------------------------------------------
+version = __version__
+release = __version__
-# If your documentation needs a minimal Sphinx version, state it here.
-#
-# needs_sphinx = '1.0'
-# Add any Sphinx extension module names here, as strings. They can be
-# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
-# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.doctest',
'sphinx.ext.viewcode',
]
-# Add any paths that contain templates here, relative to this directory.
-templates_path = ['_templates']
-# The suffix(es) of source filenames.
-# You can specify multiple suffix as a list of string:
-#
-# source_suffix = ['.rst', '.md']
+templates_path = ['_templates']
source_suffix = '.rst'
-
-# The master toctree document.
master_doc = 'index'
-# The language for content autogenerated by Sphinx. Refer to documentation
-# for a list of supported languages.
-#
-# This is also used if you do content translation via gettext catalogs.
-# Usually you set "language" from the command line for these cases.
-language = None
-# List of patterns, relative to source directory, that match files and
-# directories to ignore when looking for source files.
-# This pattern also affects html_static_path and html_extra_path .
+language = 'en'
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
-# The name of the Pygments (syntax highlighting) style to use.
-pygments_style = 'sphinx'
-
-
-# -- Options for HTML output -------------------------------------------------
-
-# The theme to use for HTML and HTML Help pages. See the documentation for
-# a list of builtin themes.
-#
-html_theme = 'alabaster'
-
-# Theme options are theme-specific and customize the look and feel of a theme
-# further. For a list of options available for each theme, see the
-# documentation.
-#
-# html_theme_options = {}
-
-# Add any paths that contain custom static files (such as style sheets) here,
-# relative to this directory. They are copied after the builtin static files,
-# so a file named "default.css" will overwrite the builtin "default.css".
-html_static_path = ['_static']
-
-# Custom sidebar templates, must be a dictionary that maps document names
-# to template names.
-#
-# The default sidebars (for documents that don't match any pattern) are
-# defined by theme itself. Builtin themes are using these templates by
-# default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
-# 'searchbox.html']``.
-#
-# html_sidebars = {}
-
-
-# -- Options for HTMLHelp output ---------------------------------------------
-
-# Output file base name for HTML help builder.
-htmlhelp_basename = 'vkdoc'
-
-
-# -- Options for LaTeX output ------------------------------------------------
-
-latex_elements = {
- # The paper size ('letterpaper' or 'a4paper').
- #
- # 'papersize': 'letterpaper',
-
- # The font size ('10pt', '11pt' or '12pt').
- #
- # 'pointsize': '10pt',
-
- # Additional stuff for the LaTeX preamble.
- #
- # 'preamble': '',
-
- # Latex figure (float) alignment
- #
- # 'figure_align': 'htbp',
-}
-
-# Grouping the document tree into LaTeX files. List of tuples
-# (source start file, target name, title,
-# author, documentclass [howto, manual, or own class]).
-latex_documents = [
- (master_doc, 'vk.tex', 'Vk Documentation', 'Dmitry Voronin', 'manual'),
-]
-
-
-# -- Options for manual page output ------------------------------------------
-
-# One entry per manual page. List of tuples
-# (source start file, name, description, authors, manual section).
-man_pages = [
- (master_doc, 'vk', 'Vk Documentation', [author], 1),
-]
-
-
-# -- Options for Texinfo output ----------------------------------------------
-
-# Grouping the document tree into Texinfo files. List of tuples
-# (source start file, target name, title, author,
-# dir menu entry, description, category)
-texinfo_documents = [
- (master_doc, 'vk', 'Vk Documentation', author, 'vk', 'One line description of project.', 'Miscellaneous'),
-]
-
-
-# -- Extension configuration -------------------------------------------------
+html_theme = 'sphinx_rtd_theme'
diff --git a/docs/customizing.rst b/docs/customizing.rst
index 8a31341..3f62fe8 100644
--- a/docs/customizing.rst
+++ b/docs/customizing.rst
@@ -2,9 +2,9 @@
Customizing
===========
-Session classes
+API classes
---------------
-Session classes are ready for customizing.
+API classes are ready for customizing.
-.. autoclass:: vk.Session
+.. autoclass:: vk.API
diff --git a/docs/how-it-works.rst b/docs/how-it-works.rst
deleted file mode 100644
index 6af7968..0000000
--- a/docs/how-it-works.rst
+++ /dev/null
@@ -1,24 +0,0 @@
-
-First request
-=============
-
-.. code:: python
-
- >>> import vk
- >>> api = vk.API(v=5)
- >>> api.users.get(user_id=1)
- [{'first_name': 'Pavel', 'last_name': 'Durov', 'id': 1}]
-
-
-How it works
-============
-
-When we call
-
-Need-request -> Check access token
-If no token -> Try to get
-
-Try to get -> If we have user_login and user_password -> Get token
-Do-request
-
-If bad access token -> self.access_token = None via self.on_bad_access_token
diff --git a/docs/make.bat b/docs/make.bat
deleted file mode 100644
index 6618512..0000000
--- a/docs/make.bat
+++ /dev/null
@@ -1,248 +0,0 @@
-@ECHO OFF
-
-REM Command file for Sphinx documentation
-
-if "%SPHINXBUILD%" == "" (
- set SPHINXBUILD=sphinx-build
-)
-set BUILDDIR=_build
-set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .
-set I18NSPHINXOPTS=%SPHINXOPTS% .
-if NOT "%PAPER%" == "" (
- set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
- set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS%
-)
-
-if "%1" == "" goto help
-
-if "%1" == "help" (
- :help
- echo.Please use `make ^` where ^ is one of
- echo. html to make standalone HTML files
- echo. dirhtml to make HTML files named index.html in directories
- echo. singlehtml to make a single large HTML file
- echo. pickle to make pickle files
- echo. json to make JSON files
- echo. htmlhelp to make HTML files and a HTML help project
- echo. qthelp to make HTML files and a qthelp project
- echo. devhelp to make HTML files and a Devhelp project
- echo. epub to make an epub
- echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter
- echo. text to make text files
- echo. man to make manual pages
- echo. texinfo to make Texinfo files
- echo. gettext to make PO message catalogs
- echo. changes to make an overview over all changed/added/deprecated items
- echo. xml to make Docutils-native XML files
- echo. pseudoxml to make pseudoxml-XML files for display purposes
- echo. linkcheck to check all external links for integrity
- echo. doctest to run all doctests embedded in the documentation if enabled
- goto end
-)
-
-if "%1" == "clean" (
- for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
- del /q /s %BUILDDIR%\*
- goto end
-)
-
-
-%SPHINXBUILD% 2> nul
-if errorlevel 9009 (
- echo.
- echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
- echo.installed, then set the SPHINXBUILD environment variable to point
- echo.to the full path of the 'sphinx-build' executable. Alternatively you
- echo.may add the Sphinx directory to PATH.
- echo.
- echo.If you don't have Sphinx installed, grab it from
- echo.http://sphinx-doc.org/
- exit /b 1
-)
-
-if "%1" == "html" (
- %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
- if errorlevel 1 exit /b 1
- echo.
- echo.Build finished. The HTML pages are in %BUILDDIR%/html.
- goto end
-)
-
-if "%1" == "livehtml" (
- sphinx-autobuild -b html %ALLSPHINXOPTS% %BUILDDIR%/html
- if errorlevel 1 exit /b 1
- goto end
-)
-
-if "%1" == "dirhtml" (
- %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
- if errorlevel 1 exit /b 1
- echo.
- echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
- goto end
-)
-
-if "%1" == "singlehtml" (
- %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml
- if errorlevel 1 exit /b 1
- echo.
- echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.
- goto end
-)
-
-if "%1" == "pickle" (
- %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
- if errorlevel 1 exit /b 1
- echo.
- echo.Build finished; now you can process the pickle files.
- goto end
-)
-
-if "%1" == "json" (
- %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
- if errorlevel 1 exit /b 1
- echo.
- echo.Build finished; now you can process the JSON files.
- goto end
-)
-
-if "%1" == "htmlhelp" (
- %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
- if errorlevel 1 exit /b 1
- echo.
- echo.Build finished; now you can run HTML Help Workshop with the ^
-.hhp project file in %BUILDDIR%/htmlhelp.
- goto end
-)
-
-if "%1" == "qthelp" (
- %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
- if errorlevel 1 exit /b 1
- echo.
- echo.Build finished; now you can run "qcollectiongenerator" with the ^
-.qhcp project file in %BUILDDIR%/qthelp, like this:
- echo.^> qcollectiongenerator %BUILDDIR%\qthelp\Vk.qhcp
- echo.To view the help file:
- echo.^> assistant -collectionFile %BUILDDIR%\qthelp\Vk.ghc
- goto end
-)
-
-if "%1" == "devhelp" (
- %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp
- if errorlevel 1 exit /b 1
- echo.
- echo.Build finished.
- goto end
-)
-
-if "%1" == "epub" (
- %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub
- if errorlevel 1 exit /b 1
- echo.
- echo.Build finished. The epub file is in %BUILDDIR%/epub.
- goto end
-)
-
-if "%1" == "latex" (
- %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
- if errorlevel 1 exit /b 1
- echo.
- echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
- goto end
-)
-
-if "%1" == "latexpdf" (
- %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
- cd %BUILDDIR%/latex
- make all-pdf
- cd %BUILDDIR%/..
- echo.
- echo.Build finished; the PDF files are in %BUILDDIR%/latex.
- goto end
-)
-
-if "%1" == "latexpdfja" (
- %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
- cd %BUILDDIR%/latex
- make all-pdf-ja
- cd %BUILDDIR%/..
- echo.
- echo.Build finished; the PDF files are in %BUILDDIR%/latex.
- goto end
-)
-
-if "%1" == "text" (
- %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text
- if errorlevel 1 exit /b 1
- echo.
- echo.Build finished. The text files are in %BUILDDIR%/text.
- goto end
-)
-
-if "%1" == "man" (
- %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man
- if errorlevel 1 exit /b 1
- echo.
- echo.Build finished. The manual pages are in %BUILDDIR%/man.
- goto end
-)
-
-if "%1" == "texinfo" (
- %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo
- if errorlevel 1 exit /b 1
- echo.
- echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo.
- goto end
-)
-
-if "%1" == "gettext" (
- %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale
- if errorlevel 1 exit /b 1
- echo.
- echo.Build finished. The message catalogs are in %BUILDDIR%/locale.
- goto end
-)
-
-if "%1" == "changes" (
- %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
- if errorlevel 1 exit /b 1
- echo.
- echo.The overview file is in %BUILDDIR%/changes.
- goto end
-)
-
-if "%1" == "linkcheck" (
- %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
- if errorlevel 1 exit /b 1
- echo.
- echo.Link check complete; look for any errors in the above output ^
-or in %BUILDDIR%/linkcheck/output.txt.
- goto end
-)
-
-if "%1" == "doctest" (
- %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
- if errorlevel 1 exit /b 1
- echo.
- echo.Testing of doctests in the sources finished, look at the ^
-results in %BUILDDIR%/doctest/output.txt.
- goto end
-)
-
-if "%1" == "xml" (
- %SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml
- if errorlevel 1 exit /b 1
- echo.
- echo.Build finished. The XML files are in %BUILDDIR%/xml.
- goto end
-)
-
-if "%1" == "pseudoxml" (
- %SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml
- if errorlevel 1 exit /b 1
- echo.
- echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml.
- goto end
-)
-
-:end
diff --git a/docs/usage.rst b/docs/usage.rst
index fb2cabb..10727d5 100644
--- a/docs/usage.rst
+++ b/docs/usage.rst
@@ -7,14 +7,6 @@ API method request example
Get user info with **user id** equal to 1.
- .. code:: python
-
- >>> import vk
- >>> session = vk.Session()
- >>> api = vk.API(session)
- >>> api.users.get(user_ids=1)
- [{'first_name': 'Pavel', 'last_name': 'Durov', 'id': 1}]
-
`vk.API` class object is used to create API request and send it via `vk.Session` class object.
Session object is used by API object to manage access token, send API request, get JSON response,
parse and return it.
@@ -29,18 +21,13 @@ vk.API
------
`vk.API` gets Session or subclass object as first argument,
-**kwargs as API method default args and `timeout` kwarg.
+\**kwargs as API method default args and `timeout` kwarg.
See https://vk.com/dev/api_requests for full list of common args.
The most useful is `v` - API version and `lang` - language of responses.
All API methods that can be called from server should be supported.
See https://vk.com/dev/methods for detailed API help.
- .. code:: python
-
- session = vk.Session()
- api = vk.API(session, v='5.35', lang='ru', timeout=10)
- api.method.name(param=value)
vk.Session
----------
@@ -49,22 +36,12 @@ vk.Session
It will send access token with every API request after first "Autorization failed" error.
`Session` class can use only ready access token and raises error if can't get it.
-.. code:: python
-
- session = vk.Session(access_token='5ecre7')
- api = vk.API(session)
- ...
vk.AuthSession
--------------
It's `vk.Session` subclass. Can get access token using app id and user credentials.
-.. code:: python
-
- session = vk.AuthSession(app_id='appid', user_login='jake@gmail.com', user_password='Finn')
- api = vk.API(session)
- ...
Debugging
---------
@@ -72,6 +49,7 @@ Debugging
To understand that happens you can enable debug mode.
.. code:: python
+
vk.logger.setLevel('DEBUG')
`vk.logger` is Python standard library `logging.Logger` instance.
diff --git a/pyproject.toml b/pyproject.toml
new file mode 100644
index 0000000..419f7f8
--- /dev/null
+++ b/pyproject.toml
@@ -0,0 +1,57 @@
+[build-system]
+requires = ["setuptools"]
+build-backend = "setuptools.build_meta"
+
+[project]
+name = "vk"
+description = "Python vk.com API wrapper"
+license = { text = "MIT" }
+authors = [
+ { name = "Dmitry Voronin", email = "dimka665@gmail.com" }
+]
+maintainers = [
+ { name = "Yaroslav Kikel", email = "yaroslav.kikel.06@inbox.ru"}
+]
+dependencies = [
+ "requests~=2.24"
+]
+urls.Documentation = "https://vk.readthedocs.io"
+urls.Homepage = "https://github.com/voronind/vk"
+urls.Source = "https://github.com/voronind/vk"
+urls.Tracker = "https://github.com/voronind/vk/issues"
+readme = "README.md"
+keywords = ["vk.com", "api", "vk", "wrappper"]
+classifiers = [
+ "Development Status :: 5 - Production/Stable",
+ "Intended Audience :: Developers",
+ "License :: OSI Approved :: MIT License",
+ "Operating System :: OS Independent",
+ "Programming Language :: Python",
+ "Programming Language :: Python :: 3",
+ "Programming Language :: Python :: 3 :: Only",
+ "Programming Language :: Python :: 3.7",
+ "Programming Language :: Python :: 3.8",
+ "Programming Language :: Python :: 3.9",
+ "Programming Language :: Python :: 3.10",
+ "Programming Language :: Python :: Implementation :: CPython",
+ "Programming Language :: Python :: Implementation :: PyPy",
+ "Topic :: Software Development :: Libraries :: Python Modules",
+]
+dynamic = ["version"]
+
+[project.optional-dependencies]
+test = [
+ "pytest>=6",
+ "pytest-cov>=2.7"
+]
+docs = [
+ "sphinx>=4",
+ "sphinx-autobuild>=2021",
+ "sphinx-rtd-theme>=1.0.0"
+]
+
+[tool.setuptools.packages.find]
+where = ["src"]
+
+[tool.setuptools.dynamic]
+version = {attr = "vk.__version__"}
diff --git a/setup.cfg b/setup.cfg
deleted file mode 100644
index 665595b..0000000
--- a/setup.cfg
+++ /dev/null
@@ -1,72 +0,0 @@
-[metadata]
-name = vk
-version = attr: vk.__version__
-
-author = Dmitry Voronin
-author_email = dimka665@gmail.com
-url = https://github.com/voronind/vk
-
-description = Python vk.com API wrapper
-keywords = vk.com api vk wrappper
-
-license = MIT License
-license_file = LICENSE
-classifiers =
- License :: OSI Approved :: MIT License
- Programming Language :: Python :: 3.5
- Programming Language :: Python :: 3.6
- Programming Language :: Python :: Implementation :: PyPy
- Intended Audience :: Developers
- Topic :: Software Development :: Libraries :: Python Modules
-
-[options]
-packages = find:
-
-[tox:tox]
-envlist = py35, py36, pypy3, docs
-skipsdist = true
-
-[testenv]
-skipinstall = true
-passenv = TEST_APP_SERVICE_TOKEN
-deps =
- ; 2018.7.1 contains error
- pipenv<2018.7
-commands=
- pipenv install --dev --skip-lock
- pipenv run fulltest
- py35: pipenv run doctest
- py35: pipenv run build-docs
-
-[testenv:docs]
-basepython = python3.5
-deps =
- ; 2018.7.1 contains error
- pipenv<2018.7
- sphinx
-commands=
- pipenv install --skip-lock
- pipenv run doctest
- pipenv run build-docs
-
-[tool:pytest]
-testpaths = tests
-norecursedirs =
- .*/
- docs/
-
-[flake8]
-max-line-length = 120
-exclude =
- .*/,
- docs/_build/
-
-[coverage:run]
-source = vk
-branch = True
-
-[coverage:report]
-fail_under = 50
-
-[mypy]
-check_untyped_defs = yes
diff --git a/setup.py b/setup.py
deleted file mode 100644
index ee41a63..0000000
--- a/setup.py
+++ /dev/null
@@ -1,12 +0,0 @@
-from setuptools import setup
-
-from pipenv.project import Project
-from pipenv.utils import convert_deps_to_pip
-
-
-def get_packages_from_Pipfile():
- pipfile = Project(chdir=False).parsed_pipfile
- return convert_deps_to_pip(pipfile['packages'], r=False)
-
-
-setup(install_requires=get_packages_from_Pipfile())
diff --git a/src/vk/__init__.py b/src/vk/__init__.py
new file mode 100644
index 0000000..7260930
--- /dev/null
+++ b/src/vk/__init__.py
@@ -0,0 +1,5 @@
+from .session import API, CommunityAPI, UserAPI
+
+__version__ = '3.0.dev1'
+
+__all__ = (API, UserAPI, CommunityAPI)
diff --git a/vk/api.py b/src/vk/api.py
similarity index 100%
rename from vk/api.py
rename to src/vk/api.py
diff --git a/vk/exceptions.py b/src/vk/exceptions.py
similarity index 100%
rename from vk/exceptions.py
rename to src/vk/exceptions.py
diff --git a/vk/session.py b/src/vk/session.py
similarity index 99%
rename from vk/session.py
rename to src/vk/session.py
index 0d97915..98c2e72 100644
--- a/vk/session.py
+++ b/src/vk/session.py
@@ -1,11 +1,11 @@
+import logging
import re
import urllib
-import logging
import requests
-from .exceptions import VkAuthError, VkAPIError
from .api import APINamespace
+from .exceptions import VkAPIError, VkAuthError
from .utils import json_iter_parse, stringify
logger = logging.getLogger('vk')
diff --git a/vk/utils.py b/src/vk/utils.py
similarity index 97%
rename from vk/utils.py
rename to src/vk/utils.py
index 714c1c6..aaaf38d 100644
--- a/vk/utils.py
+++ b/src/vk/utils.py
@@ -1,5 +1,5 @@
import logging
-from collections import Iterable
+from typing import Iterable
logger = logging.getLogger('vk')
diff --git a/tests/conftest.py b/tests/conftest.py
index 7986fbe..1b0ead4 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -1,11 +1,10 @@
+import pytest
import requests
-from pytest import fixture
-
from vk.session import APIBase
-@fixture('session')
+@pytest.fixture(scope='session')
def v():
"""
Actual vk API version
@@ -47,7 +46,7 @@ def raise_for_status(self):
raise ValueError(self.status_code)
-@fixture
+@pytest.fixture
def response_class():
return Response
@@ -70,17 +69,17 @@ def request(self, method, url, **kwargs):
return response
-@fixture
+@pytest.fixture
def session_class():
return MockedSessionBase
-@fixture
+@pytest.fixture
def mock_requests_session(monkeypatch):
class MockedSession(MockedSessionBase):
- def mocked_request(self, verb, url, **kwargs):
+ def mocked_request(self, verb, url):
if verb == 'POST':
if url.startswith(APIBase.API_URL):
# method = url[len(vk.Session.API_URL):]
diff --git a/tests/test_api.py b/tests/test_api.py
index 2c240a6..eb2245a 100644
--- a/tests/test_api.py
+++ b/tests/test_api.py
@@ -1,34 +1,36 @@
import os
import time
-from pytest import fixture, raises
+import pytest
from vk import API
from vk.exceptions import VkAPIError
-@fixture('session')
+@pytest.fixture(scope='session')
def service_token():
return os.environ['TEST_APP_SERVICE_TOKEN']
-@fixture
+@pytest.fixture
def api(service_token, v):
return API(service_token, v=v, lang='en')
+@pytest.mark.skip
def test_v_param(service_token, v):
"""
Missed version on API instance
"""
api = API(service_token)
- with raises(VkAPIError, match='8\. Invalid request: v \(version\) is required'):
+ with pytest.raises(VkAPIError, match=r'8\. Invalid request: v \(version\) is required'):
api.getServerTime()
assert api.getServerTime(v=v) > time.time() - 10
+@pytest.mark.skip
def test_durov(api):
"""
Get users
diff --git a/tests/test_api_namespace.py b/tests/test_api_namespace.py
index 8bcb663..cc6be38 100644
--- a/tests/test_api_namespace.py
+++ b/tests/test_api_namespace.py
@@ -1,6 +1,6 @@
-from pytest import fixture
+import pytest
-from vk.api import APINamespace, APIMethod, APIRequest
+from vk.api import APIMethod, APINamespace, APIRequest
class APISessionMock:
@@ -8,7 +8,7 @@ def send(self, request):
return request
-@fixture('module')
+@pytest.fixture(scope='module')
def api_namespace():
return APINamespace(APISessionMock(), {'param': 'value'})
diff --git a/tests/test_user_api.py b/tests/test_user_api.py
index 1b5ece1..b68e481 100644
--- a/tests/test_user_api.py
+++ b/tests/test_user_api.py
@@ -1,29 +1,29 @@
-from pytest import fixture, mark
+import pytest
import vk
-@fixture
+@pytest.fixture
def user_login():
return 'user-login'
-@fixture
+@pytest.fixture
def user_password():
return 'user-password'
-@fixture
+@pytest.fixture
def app_id():
return 'app-id'
-@fixture
+@pytest.fixture
def scope():
return 'scope'
-@fixture(autouse=True)
+@pytest.fixture(autouse=True)
def mock_requests_session(monkeypatch, user_login, user_password, access_token, response_class, session_class):
class MockedSession(session_class):
@@ -51,7 +51,7 @@ def mocked_request(self, method, url, **kwargs):
monkeypatch.setattr('requests.Session', MockedSession)
-@mark.skip
+@pytest.mark.skip
def test_login(user_login, user_password, app_id, scope, access_token):
api = vk.API(user_login=user_login, user_password=user_password, app_id=app_id, scope=scope)
diff --git a/tox.ini b/tox.ini
new file mode 100644
index 0000000..e7c60ed
--- /dev/null
+++ b/tox.ini
@@ -0,0 +1,37 @@
+[tox]
+envlist = py{37,38,39,310,py37,py38}
+isolated_build = true
+skip_missing_interpreters = true
+
+[testenv]
+description = run the unit tests with pytest under {basepython}
+extras =
+ test
+commands =
+ pytest {tty:--color=yes} {posargs: \
+ --no-cov-on-fail --cov-report xml --cov-report term-missing --cov-append \
+ --cov {envsitepackagesdir}{/}vk --cov {toxinidir}{/}tests tests{/} \
+ }
+package = wheel
+
+[testenv:fix]
+description = run static analysis and style check using flake8
+passenv =
+ HOMEPATH
+ PROGRAMDATA
+skip_install = true
+deps =
+ pre-commit>=2
+commands =
+ pre-commit run --all-files
+
+[testenv:docs]
+description = build docs with sphinx
+extras =
+ docs
+commands =
+ sphinx-build docs "{toxworkdir}/docs_out" --color -b html {posargs}
+ python -c 'import pathlib; print("Documentation available under \{0\}".format((pathlib.Path(r"{toxworkdir}") / "docs_out" / "index.html").as_uri()))'
+
+[flake8]
+max-line-length = 120
diff --git a/vagrant-provision.sh b/vagrant-provision.sh
deleted file mode 100644
index c9721bb..0000000
--- a/vagrant-provision.sh
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/bash
-
-sudo apt-get update; sudo apt-get upgrade
-
-sudo apt-get install -y python-dev
-sudo apt-get install -y python3-dev python3-pip
-
-sudo pip3 install --upgrade pip virtualenv\>=15
-
-virtualenv ~/.virtualenvs/vk
-~/.virtualenvs/vk/bin/pip install -r requirements.txt
-
-echo '' >> ~/.bashrc
-echo 'source ~/.virtualenvs/vk/bin/activate' >> ~/.bashrc
-echo 'cd ~/vk' >> ~/.bashrc
-echo 'export PYTHONPATH=.' >> ~/.bashrc
diff --git a/vk/__init__.py b/vk/__init__.py
deleted file mode 100644
index 42caa51..0000000
--- a/vk/__init__.py
+++ /dev/null
@@ -1,5 +0,0 @@
-from .session import API, UserAPI, CommunityAPI
-
-__version__ = '3.0-dev'
-
-__all__ = (API, UserAPI, CommunityAPI)