2021-08-06 12:59:39 +05:30
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
#
|
|
|
|
|
# The OpenSearch Contributors require contributions made to
|
|
|
|
|
# this file be licensed under the Apache-2.0 license or a
|
|
|
|
|
# compatible open source license.
|
|
|
|
|
#
|
|
|
|
|
# Modifications Copyright OpenSearch Contributors. See
|
|
|
|
|
# GitHub history for details.
|
|
|
|
|
#
|
2020-07-02 13:15:25 -05:00
|
|
|
# Licensed to Elasticsearch B.V. under one or more contributor
|
|
|
|
|
# license agreements. See the NOTICE file distributed with
|
|
|
|
|
# this work for additional information regarding copyright
|
|
|
|
|
# ownership. Elasticsearch B.V. licenses this file to you under
|
|
|
|
|
# the Apache License, Version 2.0 (the "License"); you may
|
|
|
|
|
# not use this file except in compliance with the License.
|
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
|
#
|
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
#
|
|
|
|
|
# Unless required by applicable law or agreed to in writing,
|
|
|
|
|
# software distributed under the License is distributed on an
|
|
|
|
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
|
# KIND, either express or implied. See the License for the
|
|
|
|
|
# specific language governing permissions and limitations
|
|
|
|
|
# under the License.
|
2020-06-24 14:25:28 -05:00
|
|
|
|
|
|
|
|
import nox
|
|
|
|
|
|
|
|
|
|
SOURCE_FILES = (
|
|
|
|
|
"setup.py",
|
|
|
|
|
"noxfile.py",
|
2021-08-13 15:51:50 +05:30
|
|
|
"opensearch/",
|
|
|
|
|
"test_opensearch/",
|
2020-06-24 14:25:28 -05:00
|
|
|
"utils/",
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
2020-11-19 13:46:10 -06:00
|
|
|
@nox.session(python=["2.7", "3.4", "3.5", "3.6", "3.7", "3.8", "3.9"])
|
2020-06-24 14:25:28 -05:00
|
|
|
def test(session):
|
|
|
|
|
session.install(".")
|
|
|
|
|
session.install("-r", "dev-requirements.txt")
|
|
|
|
|
|
|
|
|
|
session.run("python", "setup.py", "test")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@nox.session()
|
2021-01-13 14:21:04 -06:00
|
|
|
def format(session):
|
|
|
|
|
session.install("black", "isort")
|
2020-06-24 14:25:28 -05:00
|
|
|
|
2021-01-13 14:21:04 -06:00
|
|
|
session.run("isort", "--profile=black", *SOURCE_FILES)
|
2020-06-24 14:25:28 -05:00
|
|
|
session.run("black", "--target-version=py27", *SOURCE_FILES)
|
2020-11-04 13:53:41 -06:00
|
|
|
session.run("python", "utils/license-headers.py", "fix", *SOURCE_FILES)
|
2020-06-24 14:25:28 -05:00
|
|
|
|
|
|
|
|
lint(session)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@nox.session()
|
|
|
|
|
def lint(session):
|
2021-06-23 08:24:47 -05:00
|
|
|
session.install("flake8", "black", "mypy", "isort", "types-requests")
|
2020-06-24 14:25:28 -05:00
|
|
|
|
2021-01-13 14:21:04 -06:00
|
|
|
session.run("isort", "--check", "--profile=black", *SOURCE_FILES)
|
2020-06-24 14:25:28 -05:00
|
|
|
session.run("black", "--target-version=py27", "--check", *SOURCE_FILES)
|
|
|
|
|
session.run("flake8", *SOURCE_FILES)
|
2020-11-04 13:53:41 -06:00
|
|
|
session.run("python", "utils/license-headers.py", "check", *SOURCE_FILES)
|
2020-06-24 14:25:28 -05:00
|
|
|
|
2020-08-31 11:07:04 -05:00
|
|
|
# Workaround to make '-r' to still work despite uninstalling aiohttp below.
|
|
|
|
|
session.run("python", "-m", "pip", "install", "aiohttp")
|
|
|
|
|
|
|
|
|
|
# Run mypy on the package and then the type examples separately for
|
|
|
|
|
# the two different mypy use-cases, ourselves and our users.
|
2021-08-13 15:51:50 +05:30
|
|
|
session.run("mypy", "--strict", "opensearch/")
|
|
|
|
|
session.run("mypy", "--strict", "test_opensearch/test_types/sync_types.py")
|
|
|
|
|
session.run("mypy", "--strict", "test_opensearch/test_types/async_types.py")
|
2020-08-31 11:07:04 -05:00
|
|
|
|
|
|
|
|
# Make sure we don't require aiohttp to be installed for users to
|
|
|
|
|
# receive type hint information from mypy.
|
2020-10-13 15:18:07 -05:00
|
|
|
session.run("python", "-m", "pip", "uninstall", "--yes", "aiohttp")
|
2021-08-13 15:51:50 +05:30
|
|
|
session.run("mypy", "--strict", "opensearch/")
|
|
|
|
|
session.run("mypy", "--strict", "test_opensearch/test_types/sync_types.py")
|
2020-08-31 11:07:04 -05:00
|
|
|
|
2020-06-24 14:25:28 -05:00
|
|
|
|
|
|
|
|
@nox.session()
|
|
|
|
|
def docs(session):
|
|
|
|
|
session.install(".")
|
2020-08-31 11:07:04 -05:00
|
|
|
session.install(
|
|
|
|
|
"-rdev-requirements.txt", "sphinx-rtd-theme", "sphinx-autodoc-typehints"
|
|
|
|
|
)
|
|
|
|
|
session.run("python", "-m", "pip", "install", "sphinx-autodoc-typehints")
|