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

Fix pyright problems #85

Merged
merged 4 commits into from
Oct 23, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/sim_recon/files/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

def read_config(input_config: str | PathLike[str]) -> RawConfigParser:
config_parser = RawConfigParser(**__PARSER_KWARGS) # type: ignore[call-overload]
config_parser.optionxform = str # Keep option cases (necessary for using as kwargs)
config_parser.optionxform = str # Keep option cases (necessary for using as kwargs) # pyright: ignore[reportAttributeAccessIssue]
config_parser.read(input_config)
return config_parser

Expand Down
5 changes: 4 additions & 1 deletion src/sim_recon/images/dv.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ def read_mrc_bound_array(file_path: str | PathLike[str]) -> BoundMrc:
raise PySimReconFileNotFoundError(f"File {file_path} not found")
logger.debug("Reading %s", file_path)
bound_array = mrc.mrc.imread(str(file_path))
return BoundMrc(bound_array, mrc=bound_array.Mrc)
return BoundMrc(
bound_array, # pyright: ignore[reportArgumentType]
mrc=bound_array.Mrc, # pyright: ignore[reportAttributeAccessIssue]
)


def get_mrc_header_array(
Expand Down
12 changes: 6 additions & 6 deletions src/sim_recon/progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ def _passthrough_logging_redirect() -> Generator[None, None, None]:

class ProgressManager:
_use_tqdm = False
progress_wrapper: _ProgressWrapperProtocol = _passthrough_wrapper
logging_redirect = _passthrough_logging_redirect
progress_wrapper: _ProgressWrapperProtocol = staticmethod(_passthrough_wrapper)
logging_redirect = staticmethod(_passthrough_logging_redirect)

@classmethod
def set_use_tqdm(cls, v: bool) -> None:
Expand Down Expand Up @@ -74,15 +74,15 @@ def tqdm_progress_wrapper(
dynamic_ncols=True,
)

cls.progress_wrapper = tqdm_progress_wrapper
cls.logging_redirect = logging_redirect_tqdm
cls.progress_wrapper = staticmethod(tqdm_progress_wrapper)
cls.logging_redirect = staticmethod(logging_redirect_tqdm)
return

except ImportError:
logger.warning("tqdm not available, cannot monitor progress")

cls.progress_wrapper = _passthrough_wrapper
cls.logging_redirect = _passthrough_logging_redirect
cls.progress_wrapper = staticmethod(_passthrough_wrapper)
cls.logging_redirect = staticmethod(_passthrough_logging_redirect)


def set_use_tqdm(v: bool) -> None:
Expand Down
11 changes: 6 additions & 5 deletions src/sim_recon/settings/formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
from typing import TYPE_CHECKING, Any

if TYPE_CHECKING:
from typing import Callable, Literal
from typing import Literal
from collections.abc import Callable

# Using the logic from RawConfigParser for consistency
_boolean_conv = RawConfigParser()._convert_to_boolean # type: ignore[attr-defined]
Expand All @@ -34,10 +35,10 @@ def wrappend_conversion_fn(v: str) -> int:
class SettingConverters:
FLOAT = Decimal
INT = int
BOOL = _boolean_conv
INT_FROM_BOOL = _bool_as_int
INT_POSITIVE = int_range_conversion_wrapper(minimum=0)
INT_GREATER_THAN_ONE = int_range_conversion_wrapper(minimum=1)
BOOL = staticmethod(_boolean_conv)
INT_FROM_BOOL = staticmethod(_bool_as_int)
INT_POSITIVE = staticmethod(int_range_conversion_wrapper(minimum=0))
INT_GREATER_THAN_ONE = staticmethod(int_range_conversion_wrapper(minimum=1))
PATH = Path


Expand Down