Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add poetry and fix problem from #23 #25

Merged
merged 44 commits into from
Jun 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
c9c3efa
Add poetry, all configs and dependences now are in pyproject.toml, pc…
Jun 5, 2022
cc394fb
Fix: Dependencies versions
Jun 5, 2022
3dabd25
Feature: Scratch files to document the project
Jun 5, 2022
697ade8
Feature: Improve CI/CD with poetry and removing pyright workaround
Jun 5, 2022
1a2c94f
Fix: Add black and isort in dependencies
Jun 5, 2022
7176fd0
Feature: Add a script to run all tests, just type "poetry run all_test"
Jun 5, 2022
13b1b19
Feature: Add something in documentations
Jun 6, 2022
ea7e6c4
Merge branch 'main' into feature/poetry
Jun 8, 2022
2de548e
Fix: Project version, Author, Python versions, Pandas version
Jun 8, 2022
8bcb394
Fix: Remove old test file documentation
Jun 8, 2022
cf96463
Fix: Remove old pyright configs
Jun 8, 2022
ec78fab
Fix: Documentation in README.md with links
Jun 8, 2022
9f44c9b
Fix: pyproject.toml python compatibility
Jun 8, 2022
34ec92a
Fix: Add tests with wheel
Jun 8, 2022
728e449
Fix: Remove pytests from tests against dist
Jun 8, 2022
7871b94
Fix: Remove Source code distribution on tests after install wheel
Jun 8, 2022
e5040a4
Fix: Using shutil to remove dir
Jun 8, 2022
9259b96
Fix: Improve local tests and fix CI tests
Jun 8, 2022
8d05d17
Fix: Add metadata to pyproject.toml when build a wheel
Jun 8, 2022
34c8305
Fix: Replace default "poetry.scripts" equivalent to console_scripts f…
Jun 8, 2022
b9677bd
Fix: Improving docs with instructions to update dependencies "poetry …
Jun 9, 2022
13d738d
Fix: Split Dev from Dist Dependencies
Jun 10, 2022
b646c9a
Refactor: Util test scripts
Jun 10, 2022
0e3ea0a
CI: All tests call poe to run
Jun 10, 2022
fbff5dc
Docs: Improving setup and test documentation
Jun 10, 2022
ce3a4f5
Refactor: Improving test_src (I still think it could be better)
Jun 10, 2022
b398255
Docs: Improving poe tests documentation
Jun 10, 2022
40836f2
Style: Apply black and isort to new scripts code
Jun 10, 2022
3cf7947
Fix: Bug when test_src code fails, test_dist continues to test
Jun 10, 2022
38a64d6
Fix: Error in test documentation
Jun 10, 2022
54a846a
Docs: Improving CLI help documentation to run tests
Jun 10, 2022
36fc564
Docs: Improving CLI help documentation to run tests
Jun 10, 2022
0f73192
CI: Runs CI only when change code or dependencies
Jun 10, 2022
1d73e23
Docs: Fix Mc Donald's english errors
Jun 10, 2022
fe21dd2
Fix: Package test
Jun 12, 2022
bc550a6
Fix: Package Test
Jun 12, 2022
d4467e0
CI: Fix package test
Jun 12, 2022
0f4eb0b
Fix: add project to sys path
Jun 12, 2022
5a17251
Refactor: Folder Hierarquie, Rollback job, refresh setup docs
Jun 14, 2022
5667178
Fix: Add rollback to test_dist
Jun 14, 2022
4c6d838
Feature: Add code style check
Jun 14, 2022
ba94941
Refactor: Improving rollback
Jun 14, 2022
3abae80
Feature: add clean cache option in local tests
Jun 14, 2022
0aaeadb
Fix: code style check
Jun 14, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 54 additions & 52 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,60 +1,62 @@
name: 'Test'

on: [push, pull_request, workflow_dispatch]
on:
push:
paths:
- /**/*.py
- /**/*.pyi
- pyproject.toml
- .github/workflows/test.yml
pull_request:
workflow_dispatch:

jobs:
test:
runs-on: ubuntu-18.04
runs-on: ${{ matrix.os }}
timeout-minutes: 10
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.8', '3.9', '3.10']

steps:
- name: Check out code
uses: actions/checkout@v2

- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: "3.9"

- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-

- name: Install dependencies
run:
python -m pip install -r tests/requirements.txt

- name: Run pyright tests
uses: gramster/pyright-action@main
with:
project: pyrighttestconfig.json
warn-partial: true

- name: Run pytest
run:
pytest tests/pandas

- name: Run mypy
run:
mypy tests/pandas typings/pandas

- name: Build wheel and install and remove typings
run: |
python setup.py build bdist_wheel
find ./dist/*.whl | xargs pip install
rm -rf typings
pip install pyright

- name: Run pyright against dist
uses: gramster/pyright-action@main
with:
project: pyrightdistconfig.json
warn-partial: true

- name: Run mypy against dist
run:
mypy tests/pandas
breno-jesus-fernandes marked this conversation as resolved.
Show resolved Hide resolved

- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Upgrade pip
run: python -m pip install --upgrade pip

- name: Install Poetry
run: pip install poetry

- name: Install project dependencies
run: poetry install -vvv --no-root

- name: Run MyPy Against Source Code
run: poetry run poe run_mypy_src

- name: Run Pyright Against Source Code
run: poetry run poe run_pyright_src

- name: Run Pytest Against Source Code
run: poetry run poe run_pytest_src

- name: Build Distribution
run: poetry run poe build_dist

- name: Install Distribution
run: poetry run poe install_dist

- name: Remove Source Code
run: poetry run poe remove_src

- name: Run Pyright Against Distribution
run: poetry run poe run_pyright_dist

- name: Run MyPy Against Distribution
run: poetry run poe run_mypy_dist
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,5 @@ dmypy.json

# Pyre type checker
.pyre/
/poetry.lock
.ideia
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ This is the home for pandas typing stubs supported by the pandas core team. The

To contribute changes to the stubs, you must include an appropriate test. See `pandas-stubs/tests` for examples.

## Build instructions
## Documentation

Use `python setup.py build bdist_wheel` to build the wheel. NOTE: `setuptools 62.3.2` is required!
- [How to set up the environment](docs/1%20-%20setup.md)
- [How to test the project](docs/2%20-%20tests.md)
- [How to follow the code style](docs/3%20-%20style.md)
- [Security stuffs](docs/4%20-%20security.md)
- [How to publish](docs/5%20-%20publish.md)

## Evolution

Expand Down
8 changes: 8 additions & 0 deletions docs/1 - setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## Set Up Environment

- Make sure you have `python >= 3.8` installed. </br></br>
- Install poetry if you still don't have: </br> `pip install poetry`</br> </br>
- Install the project dependencies with: </br> `poetry update -vvv` </br></br>
- Enter the virtual environment: </br> `poetry shell`</br></br>
- Run all tests to make sure the project is ok: </br> `poe test_all` </br></br>
- Do you want to add a new dependency? </br> `poetry add --dev foo-pkg ` </br></br>
15 changes: 15 additions & 0 deletions docs/2 - tests.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## Test

- Run local tests against source code. </br> `poe test_src` </br> </br>
- Profiles: </br>
- Default: Runs only mypy and pyright tests </br> `poe test_src --profile=default` </br>
- Pytest: Runs only pytest </br> `poe test_src --profile=pytest` </br>
- Full: Run all tests (mypy, pyright and pytests) </br> `poe test_src --profiel=full` </br> </br>

- Run local tests against distribution: </br> `poe test_dist` </br> </br>

- Run all local tests: </br> `poe test_all` </br> </br>

- Forgot some command? </br>`poe --help` </br> </br>

- These tests originally came from https://github.com/VirtusLab/pandas-stubs.
5 changes: 5 additions & 0 deletions docs/3 - style.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Code style

- It's important to follow the code style from the project:
- poetry run black pandas-stubs tests scripts
- poetry run isort pandas-stubs tests scripts
3 changes: 3 additions & 0 deletions docs/4 - security.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Security

-
3 changes: 3 additions & 0 deletions docs/5 - publish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Publish

You know ... just type "poetry publish pandas-stubs"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
130 changes: 129 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,126 @@
[tool.poetry]
name = "pandas-stubs"
version = "1.4.2.220608"
description = "Type annotations for pandas"
authors = ["The Pandas Development Team <[email protected]>"]
license = "BSD-3-Clause"
readme = "README.md"
homepage = "https://pandas.pydata.org"
repository = "https://github.com/pandas-dev/pandas-stubs"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Topic :: Scientific/Engineering"
]
packages = [
{ "include" = "pandas-stubs"}
]

[tool.poetry.urls]
"Bug Tracker" = "https://github.com/pandas-dev/pandas-stubs/issues"
"Documentation" = "https://pandas.pydata.org/pandas-docs/stable"
"Source Code" = "https://github.com/pandas-dev/pandas-stubs"

[tool.poetry.dependencies]
python = ">=3.8,<3.11"
pandas = "1.4.2"
typing-extensions = ">=4.2.0"
matplotlib = ">=3.3.2"

[tool.poetry.dev-dependencies]
mypy = ">=0.960"
pytest = ">=7.1.2"
pyright = ">=1.1.251"
black = ">=22.3.0"
isort = ">=5.10.1"
poethepoet = ">=0.13.1"
loguru = ">=0.6.0"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.poe.tasks.check_style]
help = "Local Code Style Check"
script = "scripts.style:check_style"

[tool.poe.tasks.test_src]
help = "LOCAL Test | Run tests against source code version: \"poe test_src -p=<profile>\""
script = "scripts.test:test_src(profile, clean_cache)"

[[tool.poe.tasks.test_src.args]]
help = "\"default\" (mypy + pyright) or \"pytest\" (pytest only) or \"full\" (mypy + pyright + pytest)"
name = "profile"
options = ["-p", "--profile"]
default = "default"

[[tool.poe.tasks.test_src.args]]
help = "remove mypy and pytest cache folders"
name = "clean-cache"
options = ["-c", "--clean_cache"]
default = false

[tool.poe.tasks.test_dist]
help = "Local Test | Run tests against distribuition version: \"poe test_dist\""
script = "scripts.test:test_dist(clean_cache)"

[[tool.poe.tasks.test_dist.args]]
help = "remove mypy and pytest cache folders"
name = "clean-cache"
options = ["-c", "--clean_cache"]
default = false

[tool.poe.tasks.test_all]
help = "Local Test | Run tests against source code and distribuition version: \"poe test_all\""
script = "scripts.test:test_all(clean_cache)"

[[tool.poe.tasks.test_all.args]]
help = "remove mypy and pytest cache folders"
name = "clean-cache"
options = ["-c", "--clean_cache"]
default = false

[tool.poe.tasks.run_mypy_src]
help = "CI Test | Run mypy against source code"
script = "scripts.test.procedures:run_mypy_src"

[tool.poe.tasks.run_pyright_src]
help = "CI Test | Run pyright against source code"
script = "scripts.test.procedures:run_pyright_src"

[tool.poe.tasks.run_pytest_src]
help = "CI Test | Run pytest against source code"
script = "scripts.test.procedures:run_pytest_src"

[tool.poe.tasks.build_dist]
help = "CI Test | Build distribuition"
script = "scripts.test.procedures:build_dist"

[tool.poe.tasks.install_dist]
help = "CI Test | Install distribuition"
script = "scripts.test.procedures:install_dist"

[tool.poe.tasks.remove_src]
help = "CI Test | Remove source code"
script = "scripts.test.procedures:remove_src"

[tool.poe.tasks.run_mypy_dist]
help = "CI Test | Run mypy against distribuition"
script = "scripts.test.procedures:run_mypy_dist"

[tool.poe.tasks.run_pyright_dist]
help = "CI Test | Run pyright against distribuition"
script = "scripts.test.procedures:run_pyright_dist"

[tool.black]
line_length = 88
target_version = ["py39"]
Expand Down Expand Up @@ -41,7 +164,6 @@ extra_standard_library = [

[tool.mypy]
# Import discovery
mypy_path = "typings"
namespace_packages = false
explicit_package_bases = false
ignore_missing_imports = true
Expand Down Expand Up @@ -86,3 +208,9 @@ strict_equality = true
show_error_context = false
show_column_numbers = false
show_error_codes = true

[tool.pyright]
typeCheckingMode = "basic"
stubPath = "."
include = ["tests", "pandas-stubs"]
useLibraryCodeForTypes = true
4 changes: 0 additions & 4 deletions pyrightdistconfig.json

This file was deleted.

8 changes: 0 additions & 8 deletions pyrighttestconfig.json

This file was deleted.

5 changes: 0 additions & 5 deletions runtests.bat

This file was deleted.

5 changes: 0 additions & 5 deletions runtests.sh

This file was deleted.

28 changes: 28 additions & 0 deletions scripts/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import sys

from loguru import logger
from pathlib import Path

pkg_path = [x for x in sys.path if x.endswith('site-packages')]

if not Path(fr'{pkg_path[0]}/my_paths.pth').exists():
with open(fr'{pkg_path[0]}/my_paths.pth', 'w') as file:
file.write(str(Path.cwd()))


config = {
"handlers": [
{
"sink": sys.stderr,
"format": (
"<level>\n"
"===========================================\n"
"{message}\n"
"===========================================\n"
"</level>"
),
}
]
}

logger.configure(**config)
Loading