Skip to content

Conversation

@AbdelRahmanRahal
Copy link
Contributor

This fixes any type errors raised when passing some list object to Spinner.

All tests that aren't skipped pass. 1 unrelated warning.

See tests output
================================================================== warnings summary ===================================================================
tests/test_stream.py::test_stream_parameter_with_other_parameters[kwargs1]
  /mnt/c/Users/bodbo/OneDrive/Documents/GitHub/yaspin/yaspin/core.py:172: UserWarning: color, on_color and attrs are not supported when output stream is not a TTY
    self._color = self._set_color(color) if color else color

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
============================================== 3034 passed, 1758 skipped, 1 warning in 86.39s (0:01:26) ===============================================

closes #260

This fixes any type errors raised when passing some list object to `Spinner`.

closes pavdmyt#260
@pavdmyt
Copy link
Owner

pavdmyt commented Nov 8, 2025

@AbdelRahmanRahal
Copy link
Contributor Author

AbdelRahmanRahal commented Nov 8, 2025

Relevant mypy error
yaspin/core.py:811: error: Incompatible types in assignment (expression has type "list[Any] | tuple[Any, ...]", variable has type "list[str] | None")  [assignment]
                    uframes_seq = spinner.frames

My initial call was right.

I changed it back to

@dataclass
class Spinner:
    frames: str | list[str]
    interval: int

and the mypy checks pass.

$ mypy yaspin
Success: no issues found in 5 source files

Should I set it like this for now or should I edit the source code further to accommodate the Sequence[str] type?

@pavdmyt
Copy link
Owner

pavdmyt commented Nov 10, 2025

Let's use Sequence, as it is more generic and flexible. Also, please use frames: Sequence[str], as annotating something as str | Sequence[str] is redundant (my initial suggestion was wrong).

To make mypy checks happy, you need to fix this isinstance check:

         # TODO (pavdmyt): support any type that implements iterable
-        if isinstance(spinner.frames, list | tuple):
+        if isinstance(spinner.frames, Sequence):

`frames` is now `Sequence[str]`

mypy checks pass
@AbdelRahmanRahal
Copy link
Contributor Author

I was scared to update the original checks but since I got the go, here you go!

pytests and mypy checks pass

@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.68%. Comparing base (3ca61d2) to head (b2bed11).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #261   +/-   ##
=======================================
  Coverage   94.68%   94.68%           
=======================================
  Files           5        5           
  Lines         414      414           
=======================================
  Hits          392      392           
  Misses         22       22           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@pavdmyt pavdmyt merged commit f2fc49a into pavdmyt:master Nov 12, 2025
12 checks passed
@pavdmyt
Copy link
Owner

pavdmyt commented Nov 12, 2025

@AbdelRahmanRahal thanks for you contribution 👍🏼

This will be included into the next yaspin release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix type hinting issue with the Spinner class

3 participants