Skip to content

Regulate import style in python #701

@ThreeMonth03

Description

@ThreeMonth03

According to the suggestion in PEP8 and PR #696, the import statements in python files should be regulated. The statements always import module instead of module content, and the import statements use from, which are pythonic.

For example, the following codes meets the regulation. It illustrates module path by from, and it imports module by import.

from . import _pilot_core as _pcore
from . import airfoil

try:
from _modmesh import onedim as _impl # noqa: F401
except ImportError:
from .._modmesh import onedim as _impl # noqa: F401

On the contrary, there are some unregulated codes in this project, which should be refactored.
The following code doesn't point out the path using from.

import modmesh.plot.svg as svg

The following code imports module content instead of module (files).

from typing import Any, Callable
from modmesh.testing import TestBase as ModMeshTB

Metadata

Metadata

Assignees

Labels

refactorChange code without changing tests

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions