diff --git a/deptry/config.py b/deptry/config.py index 12232084..73eed46c 100644 --- a/deptry/config.py +++ b/deptry/config.py @@ -3,7 +3,6 @@ from typing import Any, Dict, List, Optional import toml -from typeguard import TypeCheckError, check_type DEFAULTS = {"ignore_dependencies": None, "ignore_directories": [".venv"], "ignore_notebooks": False} @@ -46,16 +45,10 @@ def _read_configuration_from_pyproject_toml(self) -> Optional[Dict]: def _override_with_toml_argument(self, argument: str, expected_type: Any, pyproject_toml_config: Dict) -> None: """ - If argument is found in pyproject.toml, check if it's the correct type and then override the default argument with the found value. + If argument is found in pyproject.toml, override the default argument with the found value. """ if argument in pyproject_toml_config: value = pyproject_toml_config[argument] - try: - check_type(value, expected_type) - except TypeCheckError: - raise TypeCheckError( - f"Invalid argument supplied for `{argument}` in pyproject.toml. Should be {str(expected_type)}" - ) setattr(self, argument, value) self._log_changed_by_pyproject_toml(argument, value) diff --git a/notebooks/Untitled.ipynb b/notebooks/Untitled.ipynb new file mode 100644 index 00000000..039d76f9 --- /dev/null +++ b/notebooks/Untitled.ipynb @@ -0,0 +1,138 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "064f4445-752d-48e7-bbac-72fe198e28a2", + "metadata": {}, + "outputs": [], + "source": [ + "import ast" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "6d2dda83-00d2-407a-87ff-b602b415cb5c", + "metadata": {}, + "outputs": [], + "source": [ + "root = ast.parse(\n", + "\"\"\"\n", + "x=1\n", + "import pandas as pd\n", + "from numpy import random\n", + "if x>0:\n", + " import click\n", + "elif x<0:\n", + " from typing import List\n", + "else:\n", + " import logging\n", + "\"\"\")" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "00957720-c90a-47be-bb95-4e59dcc026d3", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "root" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "729215e5-abc3-4dae-98f7-96ab7c41727a", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + } + ], + "source": [ + "for node in ast.iter_child_nodes(root):\n", + " print(node)\n", + " if isinstance(node, ast.If):\n", + " for node in ast.iter_child_nodes(node):\n", + " if isinstance(node, ast.If):\n", + " for node in ast.iter_child_nodes(node):\n", + " print(node)" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "8f70351b-1852-4628-b683-db42be55e943", + "metadata": {}, + "outputs": [ + { + "ename": "TypeError", + "evalue": "'Module' object is not subscriptable", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", + "Input \u001b[0;32mIn [6]\u001b[0m, in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m node \u001b[38;5;129;01min\u001b[39;00m ast\u001b[38;5;241m.\u001b[39miter_child_nodes(\u001b[43mroot\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m3\u001b[39;49m\u001b[43m]\u001b[49m):\n\u001b[1;32m 2\u001b[0m \u001b[38;5;28mprint\u001b[39m(node)\n", + "\u001b[0;31mTypeError\u001b[0m: 'Module' object is not subscriptable" + ] + } + ], + "source": [ + "for node in ast.iter_child_nodes(root):\n", + " print(node)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d4978dbe-2173-404f-a46a-8839e09a4e52", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.11" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/pyproject.toml b/pyproject.toml index fe9cda89..36797b47 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,7 +15,6 @@ python = ">=3.8,<3.11" toml = "^0.10.2" isort = "^5.10.1" click = "^8.1.3" -typeguard = {git = "https://github.com/agronholm/typeguard.git", rev = "master"} [tool.poetry.dev-dependencies] black = "^22.6.0"