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

Flake8 ignore #134

Merged
merged 5 commits into from Aug 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions example/division_by_zero_error.py
@@ -1 +1,2 @@
"""Example file that raises ZeroDivisionError."""
1 / 0
1 change: 1 addition & 0 deletions example/print_int_str_error.py
@@ -1,2 +1,3 @@
"""Example to raise TypeError."""
num = 1
print(num + ' one') # type: ignore
1 change: 1 addition & 0 deletions example/runs_with_error.py
@@ -1,3 +1,4 @@
"""Example to show WTPython runs your code normally until an Exception is raised."""
import sys
import time

Expand Down
15 changes: 8 additions & 7 deletions tests/test_system.py
@@ -1,3 +1,4 @@
"""Tests for the core of WTPython."""
import sys
from contextlib import contextmanager
from typing import Iterator
Expand All @@ -10,14 +11,14 @@

@contextmanager
def update_argv(args: list) -> Iterator[None]:
"""Update sys.argv"""
"""Update sys.argv."""
orig, sys.argv = sys.argv, args
yield
sys.argv = orig


def test_version() -> None:
"""Test Version is Correct"""
"""Test Version is Correct."""
assert wtpython.__version__ == "0.1"


Expand All @@ -28,8 +29,8 @@ def test_default_parse_args() -> None:
parsed = parse_arguments()

assert parsed.get('no-display') is None
assert parsed.get('copy_error') == False
assert parsed.get('clear_cache') == False
assert parsed.get('copy_error') is False
assert parsed.get('clear_cache') is False
assert parsed.get('args') == [__file__]


Expand All @@ -41,7 +42,7 @@ def test_no_display_option(args: list) -> None:
"""Test that the no-display option is set."""
with update_argv(args):
parsed = parse_arguments()
assert parsed.get('no_display') == True
assert parsed.get('no_display') is True


@pytest.mark.parametrize("args", [
Expand All @@ -52,7 +53,7 @@ def test_copy_error_option(args: list) -> None:
"""Test that the copy-error option is set."""
with update_argv(args):
parsed = parse_arguments()
assert parsed.get('copy_error') == True
assert parsed.get('copy_error') is True


@pytest.mark.parametrize("args", [
Expand All @@ -62,7 +63,7 @@ def test_clear_cache_option(args: list) -> None:
"""Test that the clear-cache option is set."""
with update_argv(args):
parsed = parse_arguments()
assert parsed.get('clear_cache') == True
assert parsed.get('clear_cache') is True


@pytest.mark.parametrize("args", [
Expand Down
20 changes: 9 additions & 11 deletions tox.ini
Expand Up @@ -9,21 +9,19 @@ max-line-length=119
exclude=.venv,__pycache__
# Ignore some of the most obnoxious linting errors.
ignore=
B311,W503,E226,S311,T000
# Missing Docstrings
D100,D104,D105,D106,D107,
# Docstring Whitespace
D203,D212,D214,D215,
D105, # Missing docstring in magic method
D107, # Missing docstring in __init__
# Docstring Quotes
D301,D302,
# Docstring Content
D400,D401,D402,D404,D405,D406,D407,D408,D409,D410,D411,D412,D413,D414,D416,D417,
# Comments
E266,
D301, # Use r"" if any backslashes in a docstring
D302, # Deprecated: Use u"" for Unicode docstrings
# Type Annotations
ANN002,ANN003,ANN101,ANN102,ANN204,ANN206
ANN002, # Missing type annotation for *args
ANN003, # Missing type annotation for **kwargs
ANN101, # Missing type annotation for self in method
ANN102, # Missing type annotation for cls in classmethod
# Testing
E712, S101
S101 # Use of Assert

[isort]
# Select the 5th style (Hanging grid grouped) to handle longer import.
Expand Down
2 changes: 1 addition & 1 deletion wtpython/__init__.py
@@ -1,2 +1,2 @@
"""wtpython"""
"""wtpython."""
__version__ = "0.1"
5 changes: 5 additions & 0 deletions wtpython/__main__.py
@@ -1,3 +1,8 @@
"""Main WTPython file.

This file parses the command line arguments, runs your program,
and then displays solutions for errors if they occur.
"""
from __future__ import annotations

import argparse
Expand Down
1 change: 1 addition & 0 deletions wtpython/backends/__init__.py
@@ -1,3 +1,4 @@
"""Backends for managing data and formatting text."""
from .search_engine import SearchEngine # noqa: F401
from .stackoverflow import StackOverflow # noqa: F401
from .trace import Trace # noqa: F401
4 changes: 4 additions & 0 deletions wtpython/backends/cache.py
@@ -1,3 +1,7 @@
"""Tools for caching requests to external APIs.

Caching is used to reduce the number of requests to external APIs.
"""
from requests_cache import CachedSession
from requests_cache.backends import FileCache

Expand Down
3 changes: 2 additions & 1 deletion wtpython/backends/search_engine.py
@@ -1,3 +1,4 @@
"""Manage data relevant to search engines."""
from urllib.parse import urlencode

from wtpython.settings import SEARCH_ENGINE
Expand All @@ -8,7 +9,7 @@
class SearchEngine:
"""Class for handling urls for search engines."""

def __init__(self, trace: Trace, engine: str = SEARCH_ENGINE):
def __init__(self, trace: Trace, engine: str = SEARCH_ENGINE) -> None:
"""Search engine object.

Args:
Expand Down
7 changes: 4 additions & 3 deletions wtpython/backends/stackoverflow.py
@@ -1,3 +1,4 @@
"""Manage data from StackOverflow."""
from __future__ import annotations

import html
Expand Down Expand Up @@ -32,7 +33,7 @@ def __init__(self, data: dict) -> None:

@property
def answer_accepted(self) -> str:
"""String indicating if the answer is accepted."""
"""Indicate if the answer is accepted."""
return ' ✔️ ' if self.data['is_accepted'] else ''

def display(self) -> str:
Expand Down Expand Up @@ -79,12 +80,12 @@ def num_answers(self) -> str:

@property
def answer_accepted(self) -> str:
"""String indicating if the question has an accepted answer."""
"""Indicate if the question has an accepted answer."""
return ' ✔️ ' if self.data['is_answered'] else ''

@property
def url(self) -> str:
"""The url for the question."""
"""Return url for the question."""
return self.data['link']

@property
Expand Down
3 changes: 2 additions & 1 deletion wtpython/backends/trace.py
@@ -1,3 +1,4 @@
"""Manage information related to the traceback object."""
import traceback
from pathlib import Path
from types import TracebackType
Expand All @@ -22,7 +23,7 @@ def __init__(self, exc: Exception) -> None:
@staticmethod
def trim_exception_traceback(tb: Optional[TracebackType]) -> Optional[TracebackType]:
"""
Trim the traceback to remove extra frames
Trim the traceback to remove extra frames.

Because of the way we are currently running the code, any traceback
created during the execution of the application will be include the
Expand Down
1 change: 1 addition & 0 deletions wtpython/displays/__init__.py
@@ -1,2 +1,3 @@
"""Modes for displaying information to the user."""
from .no_display import dump_info # noqa: F401
from .textual_display import TextualDisplay # noqa: F401
7 changes: 4 additions & 3 deletions wtpython/displays/textual_display.py
@@ -1,3 +1,4 @@
"""TUI Using Textual."""
from __future__ import annotations

import webbrowser
Expand Down Expand Up @@ -67,7 +68,7 @@ async def on_mouse_move(self, event: events.MouseMove) -> None:
self.highlighted = event.style.meta.get("index")

async def on_leave(self, event: events.Leave) -> None:
"""Clear any highlight when the mouse leave the widget"""
"""Clear any highlight when the mouse leave the widget."""
self.highlighted = None

def render(self) -> RenderableType:
Expand Down Expand Up @@ -124,7 +125,7 @@ async def update_body(self) -> None:
self.body.target_y = 0

async def action_set_index(self, index: int) -> None:
"""Set question index"""
"""Set question index."""
self.sidebar.index = index
self.index = index
await self.update_body()
Expand Down Expand Up @@ -163,7 +164,7 @@ async def action_show_traceback(self) -> None:
await self.update_body()

async def on_mount(self, event: events.Mount) -> None:
"""Main Program"""
"""Execute Main Program."""
self.title = f"{APP_NAME} | {TRACE.error}"

view = await self.push_view(DockView())
Expand Down
1 change: 1 addition & 0 deletions wtpython/exceptions.py
@@ -1,3 +1,4 @@
"""Custom Exceptions for WTPython."""
from rich import print
from rich.markdown import HorizontalRule

Expand Down
1 change: 1 addition & 0 deletions wtpython/formatters.py
@@ -1,3 +1,4 @@
"""Utility classes for formatting text."""
from typing import Any, Optional

from markdownify import MarkdownConverter
Expand Down
1 change: 1 addition & 0 deletions wtpython/settings.py
@@ -1,3 +1,4 @@
"""Default Settings for WTPython."""
from pathlib import Path

BASE_DIR = Path(__file__).resolve().parent
Expand Down