Skip to content

Commit

Permalink
chore: remove unused imports and organize used imports (#246)
Browse files Browse the repository at this point in the history
  • Loading branch information
tdstein authored Jul 29, 2024
1 parent e4ddf78 commit 8c74a63
Show file tree
Hide file tree
Showing 41 changed files with 58 additions and 100 deletions.
11 changes: 5 additions & 6 deletions examples/connect/dash/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
# mypy: ignore-errors
import os

from posit.connect.external.databricks import viewer_credentials_provider

import flask
import pandas as pd
from dash import Dash, Input, Output, dash_table, html
from databricks import sql
from databricks.sdk.service.iam import CurrentUserAPI
from databricks.sdk.core import ApiClient, Config
from databricks.sdk.service.iam import CurrentUserAPI

from dash import Dash, html, Output, Input, dash_table
import pandas as pd
import flask
from posit.connect.external.databricks import viewer_credentials_provider

DATABRICKS_HOST = os.getenv("DATABRICKS_HOST")
DATABRICKS_HOST_URL = f"https://{DATABRICKS_HOST}"
Expand Down
8 changes: 3 additions & 5 deletions examples/connect/fastapi/app.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
# -*- coding: utf-8 -*-
# mypy: ignore-errors
import os

from posit.connect.external.databricks import viewer_credentials_provider

from databricks import sql

from typing import Annotated

from databricks import sql
from fastapi import FastAPI, Header
from fastapi.responses import JSONResponse

from posit.connect.external.databricks import viewer_credentials_provider

DATABRICKS_HOST = os.getenv("DATABRICKS_HOST")
DATABRICKS_HOST_URL = f"https://{DATABRICKS_HOST}"
SQL_HTTP_PATH = os.getenv("DATABRICKS_PATH")
Expand Down
3 changes: 2 additions & 1 deletion examples/connect/flask/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
# mypy: ignore-errors
import os

from posit.connect.external.databricks import viewer_credentials_provider
from databricks import sql
from flask import Flask, request

from posit.connect.external.databricks import viewer_credentials_provider

DATABRICKS_HOST = os.getenv("DATABRICKS_HOST")
DATABRICKS_HOST_URL = f"https://{DATABRICKS_HOST}"
SQL_HTTP_PATH = os.getenv("DATABRICKS_PATH")
Expand Down
8 changes: 3 additions & 5 deletions examples/connect/shiny-python/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
import os

import pandas as pd

from posit.connect.external.databricks import viewer_credentials_provider

from databricks import sql
from databricks.sdk.service.iam import CurrentUserAPI
from databricks.sdk.core import ApiClient, Config

from databricks.sdk.service.iam import CurrentUserAPI
from shiny import App, Inputs, Outputs, Session, render, ui

from posit.connect.external.databricks import viewer_credentials_provider

DATABRICKS_HOST = os.getenv("DATABRICKS_HOST")
DATABRICKS_HOST_URL = f"https://{DATABRICKS_HOST}"
SQL_HTTP_PATH = os.getenv("DATABRICKS_PATH")
Expand Down
11 changes: 5 additions & 6 deletions examples/connect/streamlit/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@
# mypy: ignore-errors
import os

from posit.connect.external.databricks import viewer_credentials_provider

from databricks import sql
from databricks.sdk.service.iam import CurrentUserAPI
from databricks.sdk.core import ApiClient, Config

import pandas as pd
import streamlit as st
from databricks import sql
from databricks.sdk.core import ApiClient, Config
from databricks.sdk.service.iam import CurrentUserAPI
from streamlit.web.server.websocket_headers import _get_websocket_headers

from posit.connect.external.databricks import viewer_credentials_provider

DATABRICKS_HOST = os.getenv("DATABRICKS_HOST")
DATABRICKS_HOST_URL = f"https://{DATABRICKS_HOST}"
SQL_HTTP_PATH = os.getenv("DATABRICKS_PATH")
Expand Down
2 changes: 0 additions & 2 deletions integration/tests/posit/connect/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import os

from packaging import version

from posit import connect
Expand Down
2 changes: 1 addition & 1 deletion integration/tests/posit/connect/test_content.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pathlib import Path
from packaging import version

import pytest
from packaging import version

from posit import connect

Expand Down
6 changes: 4 additions & 2 deletions src/posit/connect/bundles.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
from __future__ import annotations

import io
import requests
from typing import List
from . import config, resources, tasks, urls

import requests

from . import config, resources, tasks


class BundleMetadata(resources.Resource):
Expand Down
10 changes: 5 additions & 5 deletions src/posit/connect/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

from __future__ import annotations

from requests import Response, Session
from typing import Optional, overload
from typing import overload

from . import hooks, me, urls
from requests import Response, Session

from . import hooks, me
from .auth import Auth
from .config import Config
from .oauth import OAuthIntegration
from .content import Content
from .groups import Groups
from .metrics import Metrics
from .oauth import OAuthIntegration
from .tasks import Tasks
from .users import User, Users
from .groups import Groups


class Client:
Expand Down
1 change: 0 additions & 1 deletion src/posit/connect/config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Client configuration."""

import os

from typing import Optional

from . import urls
Expand Down
2 changes: 1 addition & 1 deletion src/posit/connect/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from requests import Session

from . import tasks, urls
from . import tasks
from .bundles import Bundles
from .config import Config
from .env import EnvVars
Expand Down
2 changes: 1 addition & 1 deletion src/posit/connect/cursors.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from dataclasses import dataclass, make_dataclass
from dataclasses import dataclass
from typing import Generator, List

import requests
Expand Down
1 change: 0 additions & 1 deletion src/posit/connect/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from requests import Session

from . import urls
from .config import Config
from .resources import Resources

Expand Down
3 changes: 1 addition & 2 deletions src/posit/connect/groups.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
"""Group resources."""

from __future__ import annotations

from typing import List, overload

import requests

from . import me, urls

from .config import Config
from .paginator import Paginator
from .resources import Resource, Resources
Expand Down
2 changes: 1 addition & 1 deletion src/posit/connect/hooks.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import warnings

from http.client import responses

from requests import JSONDecodeError, Response

from .errors import ClientError
Expand Down
2 changes: 0 additions & 2 deletions src/posit/connect/me.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import requests

from . import urls

from .config import Config
from .users import User

Expand Down
2 changes: 0 additions & 2 deletions src/posit/connect/metrics/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"""Metric resources."""

from .. import resources

from . import usage
from .usage import Usage


Expand Down
2 changes: 0 additions & 2 deletions src/posit/connect/metrics/shiny_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

from typing import List, overload

from .. import urls

from ..cursors import CursorPaginator
from ..resources import Resource, Resources

Expand Down
3 changes: 1 addition & 2 deletions src/posit/connect/metrics/usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@

from requests.sessions import Session as Session

from . import shiny_usage, visits

from .. import resources
from . import shiny_usage, visits


class UsageEvent(resources.Resource):
Expand Down
2 changes: 0 additions & 2 deletions src/posit/connect/metrics/visits.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

from typing import List, overload

from .. import urls

from ..cursors import CursorPaginator
from ..resources import Resource, Resources

Expand Down
4 changes: 2 additions & 2 deletions src/posit/connect/oauth.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from __future__ import annotations

from requests import Session
from typing import Optional, TypedDict

from . import urls
from requests import Session

from .config import Config


Expand Down
1 change: 0 additions & 1 deletion src/posit/connect/paginator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import requests


# The maximum page size supported by the API.
_MAX_PAGE_SIZE = 500

Expand Down
2 changes: 0 additions & 2 deletions src/posit/connect/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

from requests.sessions import Session as Session

from . import urls

from .config import Config
from .resources import Resource, Resources

Expand Down
2 changes: 1 addition & 1 deletion src/posit/connect/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from typing import List, overload

from . import resources, urls
from . import resources


class Task(resources.Resource):
Expand Down
4 changes: 2 additions & 2 deletions src/posit/connect/users.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""User resources."""

from __future__ import annotations

from typing import List, overload

import requests

from . import me, urls

from . import me
from .config import Config
from .content import Content
from .paginator import Paginator
Expand Down
2 changes: 1 addition & 1 deletion src/posit/connect/variants.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import List

from requests import Session

from . import urls
from .config import Config
from .resources import Resource, Resources
from .tasks import Task
Expand Down
4 changes: 2 additions & 2 deletions tests/posit/connect/api.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pyjson5 as json

from pathlib import Path

import pyjson5 as json


def load_mock(path: str) -> dict:
"""
Expand Down
5 changes: 2 additions & 3 deletions tests/posit/connect/metrics/test_shiny_usage.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import responses
import requests

import responses
from responses import matchers

from posit.connect import Client, config
from posit.connect import config
from posit.connect.metrics import shiny_usage

from ..api import load_mock # type: ignore
Expand Down
2 changes: 0 additions & 2 deletions tests/posit/connect/metrics/test_usage.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import pytest
import responses

from responses import matchers

from posit import connect
from posit.connect.metrics import shiny_usage, usage, visits


from ..api import load_mock # type: ignore


Expand Down
5 changes: 2 additions & 3 deletions tests/posit/connect/metrics/test_visits.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import responses
import requests

import responses
from responses import matchers

from posit.connect import Client, config
from posit.connect import config
from posit.connect.metrics import visits

from ..api import load_mock # type: ignore
Expand Down
7 changes: 3 additions & 4 deletions tests/posit/connect/test_bundles.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import io
from unittest import mock

import pytest
import requests
import responses

from responses import matchers
from unittest import mock

from posit.connect import Client
from posit.connect.config import Config
from posit.connect.bundles import Bundle
from posit.connect.config import Config

from .api import load_mock, get_path # type: ignore
from .api import get_path, load_mock # type: ignore


class TestBundleProperties:
Expand Down
4 changes: 2 additions & 2 deletions tests/posit/connect/test_client.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from unittest.mock import MagicMock, patch

import pytest
import responses

from unittest.mock import MagicMock, patch

from posit.connect import Client

from .api import load_mock # type: ignore
Expand Down
Loading

0 comments on commit 8c74a63

Please sign in to comment.