Skip to content

Commit

Permalink
chore(imports): remove useless imports
Browse files Browse the repository at this point in the history
As detected by [ruff](https://github.com/astral-sh/ruff)

Related to freedomofpress#254, although it doesn't provide the command to lint the
codebase itself.
  • Loading branch information
almet committed Jun 5, 2024
1 parent 850199c commit 5aa4863
Show file tree
Hide file tree
Showing 35 changed files with 14 additions and 81 deletions.
2 changes: 1 addition & 1 deletion dangerzone/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
if mode == "cli":
from .cli import cli_main as main
else:
from .gui import gui_main as main
from .gui import gui_main as main # noqa: F401
2 changes: 1 addition & 1 deletion dangerzone/cli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
import sys
from typing import Any, Callable, List, Optional, TypeVar
from typing import List, Optional

import click
from colorama import Back, Fore, Style
Expand Down
8 changes: 1 addition & 7 deletions dangerzone/conversion/common.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
import asyncio
import glob
import json
import os
import re
import shutil
import subprocess
import sys
import time
from abc import abstractmethod
from typing import Callable, Dict, List, Optional, TextIO, Tuple, Union
from typing import Callable, List, Optional, TextIO, Tuple

DEFAULT_DPI = 150 # Pixels per inch
INT_BYTES = 2
Expand Down
5 changes: 1 addition & 4 deletions dangerzone/conversion/doc_to_pixels.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import asyncio
import glob
import os
import re
import shutil
import sys
from typing import Dict, List, Optional, TextIO
from typing import Dict, Optional

import fitz
import magic
Expand Down
1 change: 0 additions & 1 deletion dangerzone/conversion/errors.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import subprocess
from typing import List, Optional, Type, Union

# XXX: errors start at 128 for conversion-related issues
Expand Down
1 change: 0 additions & 1 deletion dangerzone/conversion/pixels_to_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import io
import json
import os
import shutil
import sys
from typing import Optional

Expand Down
5 changes: 0 additions & 5 deletions dangerzone/document.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import enum
import logging
import os
import platform
import secrets
import stat
import tempfile
from pathlib import Path
from typing import Optional

import appdirs

from . import errors, util

SAFE_EXTENSION = "-safe.pdf"
Expand Down
2 changes: 1 addition & 1 deletion dangerzone/errors.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import functools
import logging
import sys
from typing import Any, Callable, Sequence, TypeVar, cast
from typing import Any, Callable, TypeVar, cast

import click

Expand Down
2 changes: 0 additions & 2 deletions dangerzone/gui/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import enum
import functools
import logging
import os
import platform
import signal
import sys
import typing
import uuid
from typing import Dict, List, Optional

import click
Expand Down
1 change: 0 additions & 1 deletion dangerzone/gui/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

from ..isolation_provider.base import IsolationProvider
from ..logic import DangerzoneCore
from ..settings import Settings
from ..util import get_resource_path, replace_control_chars

log = logging.getLogger(__name__)
Expand Down
6 changes: 1 addition & 5 deletions dangerzone/gui/main_window.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import json
import logging
import os
import platform
import shutil
import subprocess
import tempfile
import typing
from multiprocessing.pool import ThreadPool
from typing import Dict, List, Optional

from colorama import Fore, Style
from typing import List, Optional

# FIXME: See https://github.com/freedomofpress/dangerzone/issues/320 for more details.
if typing.TYPE_CHECKING:
Expand Down
4 changes: 2 additions & 2 deletions dangerzone/gui/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import sys
import time
import typing
from typing import Any, Optional
from typing import Optional

from packaging import version

Expand All @@ -20,7 +20,7 @@

# XXX implict import for "markdown" module required for Cx_Freeze to build on Windows
# See https://github.com/freedomofpress/dangerzone/issues/501
import html.parser
import html.parser # noqa: F401

import markdown
import requests
Expand Down
1 change: 0 additions & 1 deletion dangerzone/isolation_provider/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import contextlib
import logging
import os
import subprocess
import sys
import tempfile
Expand Down
2 changes: 1 addition & 1 deletion dangerzone/isolation_provider/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from ..conversion import errors
from ..document import Document
from ..util import get_resource_path, get_subprocess_startupinfo, get_tmp_dir
from ..util import get_resource_path, get_subprocess_startupinfo
from .base import PIXELS_TO_PDF_LOG_END, PIXELS_TO_PDF_LOG_START, IsolationProvider

# Define startupinfo for subprocesses
Expand Down
1 change: 0 additions & 1 deletion dangerzone/isolation_provider/dummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import subprocess
import sys
import time
from pathlib import Path
from typing import Callable, Optional

from ..document import Document
Expand Down
3 changes: 1 addition & 2 deletions dangerzone/isolation_provider/qubes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import asyncio
import inspect
import io
import logging
import os
Expand All @@ -8,7 +7,7 @@
import sys
import zipfile
from pathlib import Path
from typing import IO, Callable, Optional
from typing import IO, Optional

from ..conversion import errors
from ..conversion.common import running_on_qubes
Expand Down
6 changes: 0 additions & 6 deletions dangerzone/logic.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import concurrent.futures
import gzip
import json
import logging
import pathlib
import platform
import shutil
import subprocess
import sys
from typing import Callable, List, Optional

import colorama
Expand Down
2 changes: 1 addition & 1 deletion dangerzone/settings.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json
import logging
import os
from typing import TYPE_CHECKING, Any, Dict, Optional
from typing import TYPE_CHECKING, Any, Dict

from packaging import version

Expand Down
1 change: 0 additions & 1 deletion dangerzone/util.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import pathlib
import platform
import string
import subprocess
import sys
import unicodedata
Expand Down
2 changes: 0 additions & 2 deletions dev_scripts/env.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
#!/usr/bin/env python3

import argparse
import functools
import os
import pathlib
import re
import shutil
import subprocess
import sys
Expand Down
3 changes: 0 additions & 3 deletions dev_scripts/upload-asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@

import argparse
import getpass
import inspect
import logging
import os
import pathlib
import sys
import urllib

import requests

Expand Down
4 changes: 0 additions & 4 deletions qubes/dz.ConvertDev
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
#!/usr/bin/python3

import asyncio
import glob
import io
import os
import sys
import tempfile
import zipfile


def say(msg):
Expand Down
2 changes: 0 additions & 2 deletions setup-windows.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/usr/bin/env python3
import os

from cx_Freeze import Executable, setup

with open("share/version.txt") as f:
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env python3
import os
import sys

import setuptools

Expand Down
1 change: 0 additions & 1 deletion tests/gui/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from pathlib import Path
from typing import Optional
from unittest import mock

import pytest
from pytest import MonkeyPatch
Expand Down
4 changes: 1 addition & 3 deletions tests/gui/test_main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
import pathlib
import shutil
import time
import typing

from PySide6 import QtCore, QtWidgets
from PySide6 import QtCore
from pytest import MonkeyPatch, fixture
from pytest_mock import MockerFixture
from pytestqt.qtbot import QtBot
Expand All @@ -15,7 +14,6 @@
from dangerzone.gui.logic import DangerzoneGui
from dangerzone.gui.main_window import ContentWidget
from dangerzone.gui.updater import UpdateReport, UpdaterThread
from dangerzone.util import get_version

from .. import sample_doc, sample_pdf
from . import qt_updater as updater
Expand Down
3 changes: 0 additions & 3 deletions tests/gui/test_updater.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import json
import os
import platform
import sys
import time
import typing
from pathlib import Path

import pytest
Expand All @@ -13,7 +11,6 @@
from pytestqt.qtbot import QtBot

from dangerzone import settings
from dangerzone.gui import MainWindow
from dangerzone.gui import updater as updater_module
from dangerzone.gui.updater import UpdateReport, UpdaterThread
from dangerzone.util import get_version
Expand Down
2 changes: 0 additions & 2 deletions tests/isolation_provider/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
import subprocess

import pytest
from colorama import Style
from pytest import MonkeyPatch
from pytest_mock import MockerFixture

from dangerzone.conversion import errors
Expand Down
6 changes: 0 additions & 6 deletions tests/isolation_provider/test_container.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import itertools
import json
import os
import subprocess
import time
from typing import Any, Dict

import pytest
from pytest_mock import MockerFixture

from dangerzone.document import Document
from dangerzone.isolation_provider import base
from dangerzone.isolation_provider.container import Container
from dangerzone.isolation_provider.qubes import is_qubes_native_conversion

Expand Down
2 changes: 1 addition & 1 deletion tests/isolation_provider/test_dummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from dangerzone.isolation_provider.base import IsolationProvider
from dangerzone.isolation_provider.dummy import Dummy

from .base import IsolationProviderTermination, IsolationProviderTest
from .base import IsolationProviderTermination


class DummyWait(Dummy):
Expand Down
2 changes: 0 additions & 2 deletions tests/isolation_provider/test_qubes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os
import pathlib
import signal
import subprocess
import time

Expand All @@ -10,7 +9,6 @@

from dangerzone.conversion import errors
from dangerzone.document import Document
from dangerzone.isolation_provider.base import IsolationProvider
from dangerzone.isolation_provider.qubes import (
Qubes,
is_qubes_native_conversion,
Expand Down
2 changes: 0 additions & 2 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
from __future__ import annotations

import base64
import contextlib
import copy
import os
import platform
import re
import shutil
import sys
import tempfile
Expand Down
2 changes: 0 additions & 2 deletions tests/test_document.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import os
import platform
import stat
import tempfile
from pathlib import Path
from unittest.mock import MagicMock

Expand Down
1 change: 0 additions & 1 deletion tests/test_large_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import re
import subprocess
import sys
import time
from pathlib import Path
from typing import List

Expand Down
3 changes: 1 addition & 2 deletions tests/test_settings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import collections
import json
import os
from pathlib import Path
Expand All @@ -7,7 +6,7 @@
import pytest
from pytest_mock import MockerFixture

from dangerzone.settings import *
from dangerzone.settings import SETTINGS_FILENAME, Settings


def default_settings_0_4_1() -> dict:
Expand Down

0 comments on commit 5aa4863

Please sign in to comment.