Commit Graph

40 Commits

Author SHA1 Message Date
dustinface ec5f85dfc4
mypy: Build `mypy.ini` config with exclusions dynamically (#15158)
* mypy: Build `mypy.ini` config with exclusions dynamically

* Apply suggestions from code review

* Revert suggested `check=True` because `mypy` is expected to fails here

* Only `read_text` once

* Fix exception message

* Don't `touch`

* More `joinpath`

* Revert `newline="\n"`, its python 3.10 only

See https://bugs.python.org/issue23706

* Apply suggestions

* Fail if new issues get introduced

* Print the newly introduces issues

* Handle error codes

* Add `write_file`

* Use `sys.executable`

Co-authored-by: Kyle Altendorf <sda@fstab.net>

* `mypy_failures[:-1]`

* Add an example comment

* Improve failure check

* Drop exclusions after rebase

* Drop one more exclusion after another rebase

---------

Co-authored-by: Kyle Altendorf <sda@fstab.net>
2023-05-22 16:50:13 -05:00
Kyle Altendorf d6d8eaa984
use isort from the venv when running from pre-commit (#15310)
* use isort from the venv when running from pre-commit

* remove old isort pre-commit entries
2023-05-17 10:53:02 -05:00
Matt Hauff eab43eb800
Add Chialisp pretty printer to pre-commit (#15008)
* Add chialispp port to pre-commit

* Lint files
2023-05-09 14:46:41 -05:00
Kyle Altendorf 1228892c43
force \n/lf line endings in pre-commit (#15036)
* force \n/lf line endings in pre-commit

* more

* set -o pipefail

* Revert "set -o pipefail"

This reverts commit b359ec806b.
2023-05-03 00:29:31 -05:00
Matt Hauff e5b94d34a0
Chialisp file extensions (#14996)
* Rename chialisp file extensions

* Add pre-commit check for .clvm files

* Delete sha256tree files

* remove hash files in favor of central dictionary

* Add check for missing files like hex and hash entries

* Enhance clsp pre-commit check

* Actually check hash matches

* Update tools/manage_clvm.py

Co-authored-by: Kyle Altendorf <sda@fstab.net>

* Update tools/manage_clvm.py

Co-authored-by: Kyle Altendorf <sda@fstab.net>

* Fix Windows file writing

* Fix setup.py package_data fields

* Load hash dict at runtime

* Move away from exception pattern

* Bad equality check

* Minor fixes

* remove trailing whitespace fix

---------

Co-authored-by: Kyle Altendorf <sda@fstab.net>
2023-04-18 11:27:17 -05:00
Kyle Altendorf b839dfa0c1
update black to 23.3.0 (#14537)
* unpin black

* Update setup.py

* Update .pre-commit-config.yaml

* black

* black

* 23.3.0

* cleanup
2023-04-04 12:50:58 -05:00
Kyle Altendorf 385bf99365
Run pre-commit SQL checks as a module (#14064) 2022-12-07 20:49:46 -06:00
Kyle Altendorf 7ae9f8f54b
Catch up pre-commit black (#13907)
https://github.com/Chia-Network/chia-blockchain/pull/13647
2022-11-15 18:41:27 -06:00
Brandon Butler a731c7e3c2
Update endpoint for flake8 in pre-commit config (#13913) 2022-11-15 14:30:05 -06:00
Kyle Altendorf bbd032e1c9
embrace click 8 (#13559)
* click==8.1.3, black==22.8.0

* black

* click option creator hinting

* ignores for to-be-resolved issue

* remove unused import
2022-09-29 11:24:36 -05:00
Kyle Altendorf a20ee08fce
only compile clvm for developers (#13478)
* only compile clvm for developers

* retain existing behavior for backwards compatibility

* tests/check_clvm.py becomes tools/manage_clvm.py check (and add build subcommand)

* trigger recompilation in pytest runs
2022-09-27 11:21:54 -05:00
Kyle Altendorf 789ee4f415
Add .clvm.hex pre-commit check (#12050)
* Add .clvm.hex pre-commit check

* report all results

* stuff

* maybe pass

* add todo

* explicitly define suffixes

* check for (and remove) extra hex and hash files

* remove garbage failure hex and hash files

* provide runner scripts

* matrix pre-commit checks

* maybe now

* more cross platform

* move it

* oops

* shell:

* maybe

* more configurable

* explicitly specify powershell

* tidy

* remove other stuff

* tidy

* remove existing pytest clvm hex etc checker

* add a trailing newline to decompress_block_spends.clvm.hex.sha256tree

* Update activated.ps1

* git config --global core.autocrlf false

* Update pre-commit.yml

* only check `chia/`

* typing_extensions

* typing_extensions

* removing unused typing import

* move top_level out of the rglob

* catchup dl clvm hex files

* Revert "catchup dl clvm hex files"

This reverts commit cd3d4f70b8.

* now
2022-09-12 16:08:55 -05:00
Patrick Maslana 39a24c8173
Update the version of pre-commit-hooks in the pre-commit-config.yaml file (#12896) 2022-08-16 03:32:53 -05:00
Patrick Maslana aac2583280
Update the version for flake8 in the pre-commit-config.yaml (#12895) 2022-08-16 00:25:40 -05:00
dustinface 91bc4958d1
pre-commit: Reorder hooks by runtime (#12775)
Moving `black` and `mypy` up a bit, run `flake8` as last. New order:

```
Validate SQL statements
__init__.py files
black
Check Yaml
Fix End of Files
Trim Trailing Whitespace
Check for merge conflicts
Check python ast
Debug Statements (Python)
mypy
isort
flake8
```
2022-08-09 18:23:52 -05:00
Kyle Altendorf f9fc1a1390
use language:system for pre-commit mypy (#12235) 2022-07-13 11:44:16 -05:00
Kyle Altendorf 0aa2019526
make pre-commit mypy run use regular venv (via activated shim) (#12077)
* make pre-commit mypy run use regular venv (via activated shim)

* & not Invoke-Expression

* Update activated.ps1

* install for pre-commit

* Update activated.sh

* Update .pre-commit-config.yaml
2022-06-27 12:13:22 -05:00
Arvid Norberg 5ae87189c4
Rust coin (#11807)
* use rust implementation of Coin class, from chia_rs

* bump chia_rs dependency
2022-06-13 07:21:04 -05:00
Kyle Altendorf a87e8e34ac
black the generated protocol messages code (#11786)
* black the generated protocol messages code

* Update tests/util/build_network_protocol_files.py

Co-authored-by: Arvid Norberg <arvid@libtorrent.org>

* more focused noqa

Co-authored-by: Arvid Norberg <arvid@libtorrent.org>
2022-06-08 10:21:03 -05:00
Kyle Altendorf 458697b519
reusable workflow for a single test workflow (#11722)
* reusable workflow for a single test workflow with coverage collection

* avoid needing typing-extensions to build workflow jobs

* remove incorrect coverage job

* correct enabling of pytest-monitor

* $Env:GITHUB_*

* tweak concurrency

* add explanation for use of the reusable workflow

* name: Generate matrix configuration

* correct timelord installation choice logic

* avoid * to fix coverage combining on windows

* name: Configure matrix

* bring back the conditional run

* less matrix.os.matrix

* hmm

* again

* exclude instead

* fixup JOB_FILE_NAME

* leave the final coverage step for later

* drop configuration.runs in favor of matrix excludes

* fixup os checks

* actions/cache@v3
2022-06-03 16:56:52 -05:00
Arvid Norberg 3c203e335c
add regression test for json formatting of protocol messages (#11770) 2022-06-03 12:34:03 -05:00
Kyle Altendorf 8b2f7ec24c
Add Windows CI (#10681)
* Add Windows CI

* rebuild workflows

* rebuild workflows

* try different activation

* catch up windows workflow template

* debug dir

* hard code dev extra on windows

* it is pytest

* .exe

* -m pytest for windows

* --module pytest

* Revert "debug dir"

This reverts commit 74b5bbfd92.

* debug pkg_resources import on windows

* debug tests.conftest import on windows

* rebuild workflows

* debug

* debug oops

* debug more

* debug more

* Update pytest.ini

* Update pytest.ini

* fix it

* Revert "debug more"

This reverts commit 367ed61dfa.

* Revert "debug more"

This reverts commit 772b6707c6.

* Revert "debug oops"

This reverts commit 5065c1e172.

* Revert "debug"

This reverts commit ecf721e453.

* Revert "debug tests.conftest import on windows"

This reverts commit ea71a51625.

* Revert "debug pkg_resources import on windows"

This reverts commit eb6afb1dfb.

* more warning ignore

* they're regexes...

* --numprocesses 0 for windows ci

* specify each test file individually since pytest on windows does not seem to handle the wildcards

* relative...

* select most recent supported python on windows, support INSTALL_PYTHON_VERSION

* sort test files when generating workflows

* report full python version on windows, actually use the selected version for the env

* oops

* debug dir

* skip timelord-requiring jobs on windows

* oops

* handle wildcard expansion for coverage on windows

* rebuild workflows

* download blocks and plots on windows

* correct and and or in yaml

* -d for Install.ps1

* git config --global core.autocrlf false

* add missing windows plot_sync workflow

* no check resource usage on windows

* delete outdated windows workflows that need the timelord

* catch up windows workflow template

* try again without xdist

* rebuild workflows

* Revert "try again without xdist"

This reverts commit 4bedf5f047.

* maybe now no xdist on windows

* maybe now no xdist on windows

* rebuild workflows

* debug chiapos==1.0.9

* Revert "debug chiapos==1.0.9"

This reverts commit 4b374e128a.

* debug blspy==1.0.9

* catch up windows workflow template

* rebuild workflows

* Various windows CI fixes

* Windows CI fixes and workflow updates

* ignore another warning for the keyring

* pre-commit fixup

* rebuild workflows

* catchup windows test workflows with long_lived/** and release/** setup

* Update test_full_sync.py

* Try without parallelization

* Some other tweaks for windows

* some more timeout tweaks

* more timeout tweaks for windows

* rebuild workflows

* Adjusting more timeouts

* Skip ipv6 test on windows

* More timeout tweaks

* More timeout adjustments

* More time out adjustments

* more windows tweaks

* Try running some things with -n 0

* Fix up windows test template and re-gen workflows

* Try this again

* Try all windows tests with -n 0

* misc update

* Undo some timeout changes

* Adjust timeout

* Increase timeout

* Coverage combine should combine the files in the current directory

* Trying retry test on windows

* timeout adjustment

* use tmp_path

* Few minor updates based on review

* lint fix

* Update tests/build-workflows.py

* Update tests/core/server/test_dos.py

* Try windows with pytest xdist n=2

* Check windows with xdist n=3

* Trying n=2 again

* Adjust timeout

* Update testconfig.py

* Update build-workflows.py

* Update testconfig.py

* Update .pre-commit-config.yaml

* Update testconfig.py

* Update build-workflows.py

* Update build-test-macos

* Update build-test-ubuntu

* Update build-test-windows

* skip

* Apply suggestions from code review

* tidy

* Update test_pool_config.py

Co-authored-by: Earle Lowe <e.lowe@chia.net>
Co-authored-by: Earle Lowe <30607889+emlowe@users.noreply.github.com>
2022-05-31 14:04:45 -05:00
Kyle Altendorf 0c08803ddf
update pre-commit mypy to 0.950 (#11360) 2022-04-29 18:33:51 -07:00
Kyle Altendorf fda14b5b47
restrict click to < 8.1 for black (#10923)
https://github.com/pallets/click/issues/2225

Doing this instead of updating since updating black will change several
files due to some formatting change.  I would like to take that on
separately from unbreaking CI.
2022-03-28 19:49:22 -07:00
Kyle Altendorf f0e5b5814b
bump pre-commit mypy to v0.942 (#10902) 2022-03-28 12:48:36 -07:00
Arvid Norberg d20cf06f59
fix typo and index issues in wallet database (#10273)
* fix typo in wallet_puzzle_store

* check some SQL statements

* deduplicate name SQL index

* deduplicate wallet_type index

* deduplicate wallet_id index
2022-03-25 09:28:06 -07:00
Kyle Altendorf 7850f7355a
mypy 0.941 for pre-commit (#10728) 2022-03-17 08:44:28 -07:00
Kyle Altendorf 4915477fcb
bump pre-commit mypy to 0.940 (#10672) 2022-03-14 06:08:05 -07:00
Kyle Altendorf dbeff36ae0
Add configuration locking (#10680)
* Add configuration locking

Extracted from https://github.com/Chia-Network/chia-blockchain/pull/10631

* note that fasteners will likely be replaced by filelock

* Fix test_multiple_writers on macOS

* create_all_ssl() doesn't need to be inside the config access lock

* add warnings about not using async within get_config_lock() get lock contexts

* no need to pre-touch the lock file

* .yaml.lock instead of just .lock

* test_multiple_writers() is sync

* Revert "add warnings about not using async within get_config_lock() get lock contexts"

This reverts commit 681af3835b.

* reduce lock context size in chia_init()

* use an exit stack in load_config()

* avoid config existence precheck

* only lock around the read in load_config()

* do not raise e, just raise

* tidy new imports

* fix queue empty check in test_config.py

* remove commented out code in test_config.py

* remove unused import

Co-authored-by: Jeff Cruikshank <jeff@chia.net>
2022-03-12 06:52:47 -08:00
Kyle Altendorf 1c96b21b7c
Add pytest to mypy pre-commit environment (#10397)
* Add pytest to mypy pre-commit environment

* Update .pre-commit-config.yaml
2022-02-23 18:20:52 -08:00
Kyle Altendorf e3fb3ce96e
Move black from SuperLinter to upload workflow, use 21.12b0 in pre-commit (#10103)
* black==21.12b0 in pre-commit

Match `setup.py`.

* move black from super linter to upload workflow

* black (updated)

* configure so black . works

* --check --diff for black
2022-02-20 21:33:09 -08:00
dustinface 98971de9d5
pre-commit: Add a new hook to run `isort` (#8827)
* pre-commit: Add a new hook to run `isort`

* contributing: Add hint about `isort`

* add isort to dev deps, ignore existing .py files, use black profile

* long list to lines not comma delimited

* isort: Update and sort ignore list to match latest `main`

* add bash command line to generate isort extend skip list (#3)

* add bash command line to generate extend skip list

* tidy

* isort: More files to ignore after rebase

* tests: Fix `test_wallet_user_store.py` after rebase

* Some fixes after rebase

Co-authored-by: Kyle Altendorf <sda@fstab.net>
2022-02-15 07:28:53 -08:00
Kyle Altendorf e7270df93c
Update pre-commit mypy to 0.930 (#9648)
* Update pre-commit mypy to 0.921

* Update .pre-commit-config.yaml
2022-01-06 18:59:56 -08:00
dustinface 234d121c2a
chia|tests|pre-commit: Add missing `__init__.py` files (#8758)
* chia|tests: Add missing `__init__.py` files

* check and create needed __init__.py files via pre-commit

* plotting|tests: Handle `mypy` issues introduced by the `main` rebase

* pre-commit: Run `build-init-files.py` more verbose

* tests: Ignore `__pycache__` folders in `build-init-files.py`

* Update tests/build-init-files.py

Co-authored-by: Kyle Altendorf <sda@fstab.net>

* Update tests/build-init-files.py

Co-authored-by: Kyle Altendorf <sda@fstab.net>

* tests: Add shebang, make executable, add description

To `tests/build-init-files.py`

Co-authored-by: Kyle Altendorf <sda@fstab.net>
2021-12-16 18:52:46 -08:00
Kyle Altendorf bf01b58cb4
tweak mypy config (#9368)
* tweak mypy config

* add types-click to pre-commit
2021-11-24 13:06:39 -08:00
Kyle Altendorf 1073f9d5dd
mypy: warn_unused_ignores = true (and remove some) (#9085)
* mypy: warn_unused_ignores = true (and remove some)

* catch up

* type checking tweaks

* precommit uses mypy --no-warn-unused-ignores

* revert a bit

* precommit explanatory comment

* Update .pre-commit-config.yaml

Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com>

Co-authored-by: dustinface <35775977+xdustinface@users.noreply.github.com>
2021-11-23 12:44:53 -08:00
Jeff c4e14f5c78
Peer db new serialization (#9079)
* Serialize/deserialize peer data alongside existing sqlite implementation (to be removed)

* Simplified AddressManagerStore. No longer uses sqlite and is no longer async.

* Removed aiosqlite usage from AddressManagerStore.
Added PeerStoreResolver class to determine the appropriate location for "peers.dat"
Updated initial-config.yaml to include "peers_file_path" default, replacing "peer_db_path" (similar change for "wallet_peers_path")

* Minor comment changes/additions

* Added migration from sqlite peer db.
Made AddressManagerStore's serialization async as it was right at the edge of blocking for too long.

* Minor tweaks to checking for migration

* Removed AddressManagerSQLiteStore class scaffolding

* makePeerDataSerialization now returns bytes instead of a PeerDataSerialization object

* Async file I/O for write_file_async using aiofiles
Added more tests

* Separate out the synchronous part of move_file

* Renamed write_file to files since we're opening up the capabilities a bit

* Update references to write_file

* Renamed test_write_file to test_files

* Tests covering move_file and move_file_async

* Minor refinements to behavior and tests

* Use aiofiles for reading peers.dat

* Added missing mypy typing info for aiofiles. Also added types-PyYAML to dev_dependencies so that `mypy chia tests` doesn't require running with --install-types

* Add types-aiofiles to the linting workflow

* Directory perms can now be passed into write_file_async.
Added an explicit f.flush() followed by os.fsync() after writing the temp file contents.
2021-11-19 11:12:58 -08:00
dustinface f3526a909d
tests|github|pre-commit: Improve `build-workflows.py` and make it a `pre-commit` hook (#8728)
* tests: Move `default_replacements` into `generate_replacements`

* tests: Directly use `root_test_dirs`

Instead of passing it into `subdirs`

* tests: Make `build-workflow.py` callable from everywhere

* tests: Adjust the output of `build-workflows.py`

* tests: Add `-f` to `build-workflows.py` to allow failing on CI

* github: Run `build-workflows.py`

* pre-commit: Run `build-workflows.py` as first hook

* tests: Skip DID wallet tests until they are reliable and fixed

* tests: Skip `test_using_legacy_cryptfilekeyring`

* tests|github: Drop `root_test_dirs` and just search in all directories

This removes the requirement to add new test directories to the 
`testconfig.py`. This change uncovered two more tests which were not 
enabled on CI because their parent dir's were not added to 
`root_test_dirs`.
- `tests/weight_proof/test_weight_proof.py`
- `tests/util/test_struct_stream.py`

* tests|github: Don't list test files, use `tests/dir/tests_*.py` instead

* test: Improve workflow update checks by comparing old vs new

Instead of doing a `git diff` which can lead to false positives if there
are other local changes unlrelated to test workflows. This also fixes
the issue that newly added files were not tracked by `git diff` which
means the script / the CI would trigger an alert.

* tests: Adjust `build-workflows.py` to work as expected on windows

* tests: Read/Write in bytes to avoid and detect unexpected `\r\n`

* tests: Skip `test_pool_cmdline.py`
2021-11-09 10:57:40 -08:00
dustinface 85e176fe31
pre-commit: Update some hooks (#8309)
* pre-commit: Update `flake8` to 3.9.2

* pre-commit: Update `pre-commit-hooks` to 4.0.1

* pre-commit: Update `black` to 21.8b0
2021-09-07 18:18:43 -07:00
dustinface b2fdeb2291
pre-commit: Add initial config and run it for all files (#7053)
* pre-commit: Add initial `.pre-commit-config.yaml`

* pre-commit: Apply hook `end-of-file-fixer`

* pre-commit: Apply hook `trailing-whitespace`

* pre-commit: Apply hook `debug-statements`

* contrib: Add `pre-commit` section
2021-08-02 10:48:22 -07:00