Skip to content

Commit

Permalink
[chore] ruff: ban relative imports (#23816)
Browse files Browse the repository at this point in the history
## Summary & Motivation

Internal discussion:
dagster-io/internal#11157

Relative imports are discouraged in Python. 

1. From `ruff`
[docs](https://docs.astral.sh/ruff/rules/relative-imports/):

>Why is this bad?
Absolute imports, or relative imports from siblings, are recommended by
[PEP 8](https://peps.python.org/pep-0008/#imports):
Absolute imports are recommended, as they are usually more readable and
tend to be better behaved (or at least give better error messages) if
the import system is incorrectly configured (such as when a directory
inside a package ends up on sys.path)

## How I Tested These Changes

Existing tests should pass. The only test which required tweaking was
testing line numbers lol

## Changelog [New | Bug | Docs]

> `NOCHANGELOG`
  • Loading branch information
danielgafni authored Aug 27, 2024
1 parent 90fb55e commit 053612f
Show file tree
Hide file tree
Showing 835 changed files with 4,090 additions and 3,365 deletions.
3 changes: 1 addition & 2 deletions .buildkite/dagster-buildkite/dagster_buildkite/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
from dagster_buildkite.pipelines.dagster_oss_main import build_dagster_oss_main_steps
from dagster_buildkite.pipelines.dagster_oss_nightly_pipeline import build_dagster_oss_nightly_steps
from dagster_buildkite.python_packages import PythonPackages

from .utils import buildkite_yaml_for_steps
from dagster_buildkite.utils import buildkite_yaml_for_steps

CLI_HELP = """This CLI is used for generating Buildkite YAML. Each function corresponds to an entry
point defined in `setup.py`. Buildkite invokes these entry points when loading the specification for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@

from dagster_buildkite.git import ChangedFiles
from dagster_buildkite.python_packages import PythonPackages, changed_filetypes

from .python_version import AvailablePythonVersion
from .step_builder import BuildkiteQueue
from .steps.tox import build_tox_step
from .utils import (
from dagster_buildkite.python_version import AvailablePythonVersion
from dagster_buildkite.step_builder import BuildkiteQueue
from dagster_buildkite.steps.tox import build_tox_step
from dagster_buildkite.utils import (
BuildkiteLeafStep,
BuildkiteTopLevelStep,
GroupStep,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from typing import List

from ..package_spec import PackageSpec
from ..python_version import AvailablePythonVersion
from ..steps.packages import build_steps_from_package_specs, gcp_creds_extra_cmds
from ..utils import BuildkiteStep
from dagster_buildkite.package_spec import PackageSpec
from dagster_buildkite.python_version import AvailablePythonVersion
from dagster_buildkite.steps.packages import build_steps_from_package_specs, gcp_creds_extra_cmds
from dagster_buildkite.utils import BuildkiteStep


def build_dagster_oss_nightly_steps() -> List[BuildkiteStep]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
from enum import Enum
from typing import Dict, List, Optional

from .images.versions import BUILDKITE_TEST_IMAGE_VERSION
from .python_version import AvailablePythonVersion
from .utils import CommandStep, safe_getenv
from dagster_buildkite.images.versions import BUILDKITE_TEST_IMAGE_VERSION
from dagster_buildkite.python_version import AvailablePythonVersion
from dagster_buildkite.utils import CommandStep, safe_getenv

DEFAULT_TIMEOUT_IN_MIN = 25

Expand Down
17 changes: 8 additions & 9 deletions .buildkite/dagster-buildkite/dagster_buildkite/steps/dagster.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
from glob import glob
from typing import List

from dagster_buildkite.defines import GIT_REPO_ROOT
from dagster_buildkite.python_packages import PythonPackages

from ..defines import GIT_REPO_ROOT
from ..python_version import AvailablePythonVersion
from ..step_builder import CommandStepBuilder
from ..utils import (
from dagster_buildkite.python_version import AvailablePythonVersion
from dagster_buildkite.step_builder import CommandStepBuilder
from dagster_buildkite.steps.helm import build_helm_steps
from dagster_buildkite.steps.integration import build_integration_steps
from dagster_buildkite.steps.packages import build_library_packages_steps
from dagster_buildkite.steps.test_project import build_test_project_steps
from dagster_buildkite.utils import (
BuildkiteStep,
CommandStep,
GroupStep,
Expand All @@ -19,10 +22,6 @@
skip_if_no_python_changes,
skip_if_no_yaml_changes,
)
from .helm import build_helm_steps
from .integration import build_integration_steps
from .packages import build_library_packages_steps
from .test_project import build_test_project_steps

branch_name = safe_getenv("BUILDKITE_BRANCH")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@

from dagster_buildkite.git import ChangedFiles
from dagster_buildkite.package_spec import PackageSpec

from ..python_version import AvailablePythonVersion
from ..step_builder import CommandStepBuilder
from ..utils import CommandStep, is_feature_branch
from dagster_buildkite.python_version import AvailablePythonVersion
from dagster_buildkite.step_builder import CommandStepBuilder
from dagster_buildkite.utils import CommandStep, is_feature_branch


def skip_if_no_dagster_ui_components_changes():
Expand Down
17 changes: 12 additions & 5 deletions .buildkite/dagster-buildkite/dagster_buildkite/steps/docs.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
from typing import List

from dagster_buildkite.python_version import AvailablePythonVersion
from dagster_buildkite.step_builder import CommandStepBuilder
from dagster_buildkite.steps.packages import (
build_dagster_ui_screenshot_steps,
build_example_packages_steps,
)
from dagster_buildkite.steps.tox import build_tox_step

from ..python_version import AvailablePythonVersion
from ..step_builder import CommandStepBuilder
from ..utils import BuildkiteLeafStep, BuildkiteStep, GroupStep, skip_if_no_docs_changes
from .packages import build_dagster_ui_screenshot_steps, build_example_packages_steps
from dagster_buildkite.utils import (
BuildkiteLeafStep,
BuildkiteStep,
GroupStep,
skip_if_no_docs_changes,
)


def build_docs_steps() -> List[BuildkiteStep]:
Expand Down
8 changes: 4 additions & 4 deletions .buildkite/dagster-buildkite/dagster_buildkite/steps/helm.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import os
from typing import List

from ..package_spec import PackageSpec
from ..python_version import AvailablePythonVersion
from ..step_builder import CommandStepBuilder
from ..utils import (
from dagster_buildkite.package_spec import PackageSpec
from dagster_buildkite.python_version import AvailablePythonVersion
from dagster_buildkite.step_builder import CommandStepBuilder
from dagster_buildkite.utils import (
BuildkiteLeafStep,
BuildkiteStep,
CommandStep,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,23 @@

import packaging.version

from ..defines import GCP_CREDS_FILENAME, GCP_CREDS_LOCAL_FILE, LATEST_DAGSTER_RELEASE
from ..package_spec import PackageSpec, UnsupportedVersionsFunction
from ..python_version import AvailablePythonVersion
from ..step_builder import BuildkiteQueue
from ..utils import (
from dagster_buildkite.defines import (
GCP_CREDS_FILENAME,
GCP_CREDS_LOCAL_FILE,
LATEST_DAGSTER_RELEASE,
)
from dagster_buildkite.package_spec import PackageSpec, UnsupportedVersionsFunction
from dagster_buildkite.python_version import AvailablePythonVersion
from dagster_buildkite.step_builder import BuildkiteQueue
from dagster_buildkite.steps.test_project import test_project_depends_fn
from dagster_buildkite.utils import (
BuildkiteStep,
BuildkiteTopLevelStep,
connect_sibling_docker_container,
has_helm_changes,
library_version_from_core_version,
network_buildkite_container,
)
from .test_project import test_project_depends_fn

SCRIPT_PATH = os.path.dirname(os.path.abspath(__file__))
DAGSTER_CURRENT_BRANCH = "current_branch"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import os
from typing import List, Optional, Set

from ..defines import GCP_CREDS_FILENAME, GCP_CREDS_LOCAL_FILE
from ..images.versions import (
from dagster_buildkite.defines import GCP_CREDS_FILENAME, GCP_CREDS_LOCAL_FILE
from dagster_buildkite.images.versions import (
BUILDKITE_BUILD_TEST_PROJECT_IMAGE_IMAGE_VERSION,
TEST_PROJECT_BASE_IMAGE_VERSION,
)
from ..python_version import AvailablePythonVersion
from ..step_builder import CommandStepBuilder
from ..utils import BuildkiteLeafStep, GroupStep
from dagster_buildkite.python_version import AvailablePythonVersion
from dagster_buildkite.step_builder import CommandStepBuilder
from dagster_buildkite.utils import BuildkiteLeafStep, GroupStep

# Some python packages depend on these images but we don't explicitly define that dependency anywhere other
# than when we construct said package's Buildkite steps. Until we more explicitly define those dependencies
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Dict, List, Optional

from ..utils import TriggerStep, safe_getenv
from dagster_buildkite.utils import TriggerStep, safe_getenv


def build_trigger_step(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ..utils import WaitStep
from dagster_buildkite.utils import WaitStep


def build_wait_step() -> WaitStep:
Expand Down
Binary file modified docs/content/api/modules.json.gz
Binary file not shown.
Binary file modified docs/content/api/searchindex.json.gz
Binary file not shown.
Binary file modified docs/content/api/sections.json.gz
Binary file not shown.
Binary file modified docs/next/public/objects.inv
Binary file not shown.
8 changes: 8 additions & 0 deletions docs/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[tool.ruff]
extend = "../pyproject.toml"

[tool.ruff.lint]
extend-ignore = [
# (relative imports): relative imports are acceptable in examples & docs
"TID252"
]
16 changes: 8 additions & 8 deletions docs/sphinx/_ext/dagster-sphinx/dagster_sphinx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@
is_public,
)
from dagster._record import get_original_class, is_record
from sphinx.application import Sphinx
from sphinx.environment import BuildEnvironment
from sphinx.ext.autodoc import (
ClassDocumenter,
ObjectMember,
Options as AutodocOptions,
)
from sphinx.util import logging
from typing_extensions import Literal, TypeAlias

from dagster_sphinx.configurable import ConfigurableDocumenter
Expand All @@ -33,6 +25,14 @@
visit_flag,
visit_inline_flag,
)
from sphinx.application import Sphinx
from sphinx.environment import BuildEnvironment
from sphinx.ext.autodoc import (
ClassDocumenter,
ObjectMember,
Options as AutodocOptions,
)
from sphinx.util import logging

from .docstring_flags import inject_object_flag, inject_param_flag

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
)
from dagster._core.definitions.configurable import ConfigurableDefinition
from dagster._serdes import ConfigurableClass

from sphinx.ext.autodoc import DataDocumenter


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import dagster._check as check
import docutils.nodes as nodes
from dagster._annotations import DeprecatedInfo, ExperimentalInfo

from sphinx.util.docutils import SphinxDirective

# ########################
Expand Down
4 changes: 4 additions & 0 deletions examples/project_analytics/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@ extend = "../../pyproject.toml"
extend-ignore = [
# (print found): Allow prints for demo purposes.
"T201",

# (relative imports): relative imports are acceptable in examples & docs
"TID252"

]
4 changes: 4 additions & 0 deletions examples/project_dagster_university_start/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ extend-ignore = [
"F401",
# (Import block is un-sorted or un-formatted): It's more important that we introduce the imports in the order they're used rather than alphabetically.
"I001",

# (relative imports): relative imports are acceptable in examples & docs
"TID252"

]
5 changes: 5 additions & 0 deletions examples/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@
# has the effect of making each example package treated as first-party, where `dagster` and
# integrations will be treated as third-party. This is appropriate for example code.
extend = "../pyproject.toml"

[tool.ruff.lint]
extend-ignore = [
"TID252"
]
36 changes: 19 additions & 17 deletions helm/dagster/schema/schema/charts/dagster/subschema/__init__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
from .busybox import Busybox as Busybox
from .compute_log_manager import ComputeLogManager as ComputeLogManager
from .daemon import Daemon as Daemon
from .flower import Flower as Flower
from .global_ import Global as Global
from .ingress import Ingress as Ingress
from .migrate import Migrate as Migrate
from .postgresql import PostgreSQL as PostgreSQL
from .python_logs import PythonLogs as PythonLogs
from .rabbitmq import RabbitMQ as RabbitMQ
from .redis import Redis as Redis
from .retention import Retention as Retention
from .run_launcher import RunLauncher as RunLauncher
from .scheduler import Scheduler as Scheduler
from .service_account import ServiceAccount as ServiceAccount
from .telemetry import Telemetry as Telemetry
from .webserver import Webserver as Webserver
from schema.charts.dagster.subschema.busybox import Busybox as Busybox
from schema.charts.dagster.subschema.compute_log_manager import (
ComputeLogManager as ComputeLogManager,
)
from schema.charts.dagster.subschema.daemon import Daemon as Daemon
from schema.charts.dagster.subschema.flower import Flower as Flower
from schema.charts.dagster.subschema.global_ import Global as Global
from schema.charts.dagster.subschema.ingress import Ingress as Ingress
from schema.charts.dagster.subschema.migrate import Migrate as Migrate
from schema.charts.dagster.subschema.postgresql import PostgreSQL as PostgreSQL
from schema.charts.dagster.subschema.python_logs import PythonLogs as PythonLogs
from schema.charts.dagster.subschema.rabbitmq import RabbitMQ as RabbitMQ
from schema.charts.dagster.subschema.redis import Redis as Redis
from schema.charts.dagster.subschema.retention import Retention as Retention
from schema.charts.dagster.subschema.run_launcher import RunLauncher as RunLauncher
from schema.charts.dagster.subschema.scheduler import Scheduler as Scheduler
from schema.charts.dagster.subschema.service_account import ServiceAccount as ServiceAccount
from schema.charts.dagster.subschema.telemetry import Telemetry as Telemetry
from schema.charts.dagster.subschema.webserver import Webserver as Webserver
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import BaseModel

from ...utils.kubernetes import ExternalImage
from schema.charts.utils.kubernetes import ExternalImage


class Busybox(BaseModel):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

from pydantic import Extra

from ...utils.utils import BaseModel, ConfigurableClass, create_json_schema_conditionals
from .config import StringSource
from schema.charts.dagster.subschema.config import StringSource
from schema.charts.utils.utils import BaseModel, ConfigurableClass, create_json_schema_conditionals


class ComputeLogManagerType(str, Enum):
Expand Down
6 changes: 3 additions & 3 deletions helm/dagster/schema/schema/charts/dagster/subschema/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

from pydantic import Extra

from ...utils import kubernetes
from ...utils.utils import BaseModel, ConfigurableClass, create_json_schema_conditionals
from .config import IntSource
from schema.charts.dagster.subschema.config import IntSource
from schema.charts.utils import kubernetes
from schema.charts.utils.utils import BaseModel, ConfigurableClass, create_json_schema_conditionals


class RunCoordinatorType(str, Enum):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from pydantic import BaseModel

from ...utils import kubernetes
from schema.charts.utils import kubernetes


class Flower(BaseModel):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from pydantic import BaseModel

from ...utils import kubernetes
from schema.charts.utils import kubernetes


class IngressPathType(str, Enum):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from pydantic import BaseModel

from ...utils.kubernetes import ExternalImage
from schema.charts.utils.kubernetes import ExternalImage


class Service(BaseModel):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pydantic import BaseModel, Field

from ...utils.kubernetes import ExternalImage
from schema.charts.utils.kubernetes import ExternalImage


class RabbitMQConfiguration(BaseModel):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

from pydantic import Extra, Field

from ...utils import kubernetes
from ...utils.utils import BaseModel, ConfigurableClass, create_json_schema_conditionals
from schema.charts.utils import kubernetes
from schema.charts.utils.utils import BaseModel, ConfigurableClass, create_json_schema_conditionals


class RunLauncherType(str, Enum):
Expand Down
Loading

1 comment on commit 053612f

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for dagster-docs ready!

✅ Preview
https://dagster-docs-9zg8ojfis-elementl.vercel.app
https://master.dagster.dagster-docs.io

Built with commit 053612f.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.