Skip to content

Commit 787b062

Browse files
authored
Add Next-Pylint, Next-Mypy, and Next-Sphinx Checks (#42923)
* add next-pylint * add next-pylint * clean import * next-mypy * next-sphinx * add pygithub dependency * clean * newlines * add dev req installs to all checks * replace a print
1 parent 0b67293 commit 787b062

File tree

10 files changed

+88
-10
lines changed

10 files changed

+88
-10
lines changed

eng/tools/azure-sdk-tools/azpysdk/black.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ def run(self, args: argparse.Namespace) -> int:
4646
executable, staging_directory = self.get_executable(args.isolate, args.command, sys.executable, package_dir)
4747
logger.info(f"Processing {package_name} for black check")
4848

49+
self.install_dev_reqs(executable, args, package_dir)
50+
4951
# install black
5052
try:
5153
install_into_venv(executable, [f"black=={BLACK_VERSION}"], package_dir)

eng/tools/azure-sdk-tools/azpysdk/import_all.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ def run(self, args: argparse.Namespace) -> int:
5555
pkg = parsed.folder
5656
executable, staging_directory = self.get_executable(args.isolate, args.command, sys.executable, pkg)
5757

58+
self.install_dev_reqs(executable, args, pkg)
59+
5860
create_package_and_install(
5961
distribution_directory=staging_directory,
6062
target_setup=pkg,

eng/tools/azure-sdk-tools/azpysdk/main.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@
1515
from .whl import whl
1616
from .import_all import import_all
1717
from .mypy import mypy
18+
from .next_mypy import next_mypy
1819
from .pylint import pylint
20+
from .next_pylint import next_pylint
1921
from .sphinx import sphinx
22+
from .next_sphinx import next_sphinx
2023
from .black import black
2124
from .ruff import ruff
2225

@@ -76,8 +79,11 @@ def build_parser() -> argparse.ArgumentParser:
7679
whl().register(subparsers, [common])
7780
import_all().register(subparsers, [common])
7881
mypy().register(subparsers, [common])
82+
next_mypy().register(subparsers, [common])
7983
pylint().register(subparsers, [common])
84+
next_pylint().register(subparsers, [common])
8085
sphinx().register(subparsers, [common])
86+
next_sphinx().register(subparsers, [common])
8187
black().register(subparsers, [common])
8288
ruff().register(subparsers, [common])
8389

eng/tools/azure-sdk-tools/azpysdk/mypy.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
PYTHON_VERSION = "3.9"
1818
MYPY_VERSION = "1.14.1"
19-
2019
ADDITIONAL_LOCKED_DEPENDENCIES = [
2120
"types-chardet==5.0.4.6",
2221
"types-requests==2.31.0.6",
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import argparse
2+
3+
from typing import Optional, List
4+
5+
from .mypy import mypy
6+
7+
class next_mypy(mypy):
8+
def __init__(self):
9+
super().__init__()
10+
11+
def register(self, subparsers: "argparse._SubParsersAction", parent_parsers: Optional[List[argparse.ArgumentParser]] = None) -> None:
12+
"""Register the next-mypy check. The next-mypy check installs the next version of mypy and runs mypy against the target package.
13+
"""
14+
parents = parent_parsers or []
15+
p = subparsers.add_parser("next-mypy", parents=parents, help="Run the mypy check with the next version of mypy")
16+
p.set_defaults(func=self.run)
17+
18+
def run(self, args: argparse.Namespace) -> int:
19+
"""Run the next-mypy check command."""
20+
args.next = True
21+
return super().run(args)
22+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import argparse
2+
3+
from typing import Optional, List
4+
5+
from .pylint import pylint
6+
7+
class next_pylint(pylint):
8+
def __init__(self):
9+
super().__init__()
10+
11+
def register(self, subparsers: "argparse._SubParsersAction", parent_parsers: Optional[List[argparse.ArgumentParser]] = None) -> None:
12+
"""Register the next-pylint check. The next-pylint check installs the next version of pylint and runs pylint against the target package.
13+
"""
14+
parents = parent_parsers or []
15+
p = subparsers.add_parser("next-pylint", parents=parents, help="Run the pylint check with the next version of pylint")
16+
p.set_defaults(func=self.run)
17+
18+
def run(self, args: argparse.Namespace) -> int:
19+
"""Run the next-pylint check command."""
20+
args.next = True
21+
return super().run(args)
22+
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import argparse
2+
3+
from typing import Optional, List
4+
5+
from .sphinx import sphinx
6+
7+
class next_sphinx(sphinx):
8+
def __init__(self):
9+
super().__init__()
10+
11+
def register(self, subparsers: "argparse._SubParsersAction", parent_parsers: Optional[List[argparse.ArgumentParser]] = None) -> None:
12+
"""Register the next-sphinx check. The next-sphinx check installs the next version of sphinx and runs sphinx against the target package.
13+
"""
14+
parents = parent_parsers or []
15+
p = subparsers.add_parser("next-sphinx", parents=parents, help="Run the sphinx check with the next version of sphinx")
16+
p.set_defaults(func=self.run)
17+
18+
p.add_argument("--inci", dest="in_ci", action="store_true", default=False)
19+
20+
21+
def run(self, args: argparse.Namespace) -> int:
22+
"""Run the next-sphinx check command."""
23+
args.next = True
24+
return super().run(args)
25+

eng/tools/azure-sdk-tools/azpysdk/pylint.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
REPO_ROOT = discover_repo_root()
1515
PYLINT_VERSION = "3.2.7"
16+
PYGITHUB_VERSION = "1.59.0"
1617

1718
class pylint(Check):
1819
def __init__(self) -> None:
@@ -48,6 +49,7 @@ def run(self, args: argparse.Namespace) -> int:
4849
logger.info(f"Processing {package_name} for pylint check")
4950

5051
# install dependencies
52+
self.install_dev_reqs(executable, args, package_dir)
5153
try:
5254
install_into_venv(executable, ["azure-pylint-guidelines-checker==0.5.6", "--index-url=https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi/simple/"], package_dir)
5355
except CalledProcessError as e:
@@ -58,7 +60,7 @@ def run(self, args: argparse.Namespace) -> int:
5860
try:
5961
if args.next:
6062
# use latest version of pylint
61-
install_into_venv(executable, ["pylint"], package_dir)
63+
install_into_venv(executable, ["pylint", f"PyGithub=={PYGITHUB_VERSION}"], package_dir)
6264
else:
6365
install_into_venv(executable, [f"pylint=={PYLINT_VERSION}"], package_dir)
6466
except CalledProcessError as e:

eng/tools/azure-sdk-tools/azpysdk/sphinx.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
SPHINX_RTD_THEME_VERSION = "3.0.2"
2323
MYST_PARSER_VERSION = "4.0.1"
2424
SPHINX_CONTRIB_JQUERY_VERSION = "4.1"
25+
PYGITHUB_VERSION = "1.59.0"
2526

2627
RST_EXTENSION_FOR_INDEX = """
2728
@@ -264,6 +265,8 @@ def run(self, args: argparse.Namespace) -> int:
264265
logger.error("This tool requires Python 3.11 or newer. Please upgrade your Python interpreter.")
265266
return 1
266267

268+
self.install_dev_reqs(executable, args, package_dir)
269+
267270
create_package_and_install(
268271
distribution_directory=staging_directory,
269272
target_setup=package_dir,
@@ -280,7 +283,7 @@ def run(self, args: argparse.Namespace) -> int:
280283
try:
281284
if args.next:
282285
install_into_venv(
283-
executable, ["sphinx", "sphinx_rtd_theme", "myst_parser", "sphinxcontrib-jquery"], package_dir
286+
executable, ["sphinx", "sphinx_rtd_theme", "myst_parser", "sphinxcontrib-jquery", f"PyGithub=={PYGITHUB_VERSION}"], package_dir
284287
)
285288
else:
286289
install_into_venv(

eng/tools/azure-sdk-tools/azpysdk/whl.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,9 @@ def run(self, args: argparse.Namespace) -> int:
4040
pkg = parsed.folder
4141
executable, staging_directory = self.get_executable(args.isolate, args.command, sys.executable, pkg)
4242

43-
print(f"Invoking check with {executable}")
44-
dev_requirements = os.path.join(pkg, "dev_requirements.txt")
43+
logger.info(f"Invoking check with {executable}")
4544

46-
if os.path.exists(dev_requirements):
47-
print(f"Installing dev_requirements at {dev_requirements}")
48-
install_into_venv(executable, [f"{dev_requirements}"], pkg)
49-
else:
50-
print("Skipping installing dev_requirements")
45+
self.install_dev_reqs(executable, args, pkg)
5146

5247
create_package_and_install(
5348
distribution_directory=staging_directory,

0 commit comments

Comments
 (0)