Skip to content

Refactor: Extract textstring instantiation to from_string#115

Merged
schwehr merged 2 commits into
mainfrom
refactor-textstring-to-from-string-6845679604730418085
Jul 19, 2026
Merged

Refactor: Extract textstring instantiation to from_string#115
schwehr merged 2 commits into
mainfrom
refactor-textstring-to-from-string-6845679604730418085

Conversation

@google-labs-jules

Copy link
Copy Markdown
Contributor

This refactors text string initialization in BitVector by deprecating the overloaded textstring kwarg logic inside __init__ into a dedicated factory constructor: @classmethod def from_string(cls, textstring: str).

All previous testing logic and methods calling set_value() with textstring were appropriately updated.


PR created automatically by Jules for task 6845679604730418085 started by @schwehr

- Removes textstring argument from BitVector.__init__ and set_value
- Simplifies string parsing into hex
- Provides class method BitVector.from_string
- Updates relevant tests
@google-labs-jules

Copy link
Copy Markdown
Contributor Author

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@schwehr

schwehr commented Jul 18, 2026

Copy link
Copy Markdown
Owner

@jules. Fix these errors from pre-commits

ty.......................................................................Failed

  • hook id: ty
  • exit code: 1

error[unknown-argument]: Argument textstring does not match any known parameter of BitVector.__init__
--> examples/demo.py:80:17
|
80 | bv3 = BitVector(textstring="hello")
| ^^^^^^^^^^^^^^^^^^
|
info: Method signature here
--> BitVector/BitVector.py:49:9
|
49 | def init(
| ^
50 | | self,
51 | | *,
52 | | size: int | None = None,
53 | | intVal: int | None = None,
54 | | bitlist: Any = None,
55 | | bitstring: str | None = None,
56 | | hexstring: str | None = None,
57 | | rawbytes: bytes | None = None,
58 | | ) -> None:
| |
____^
|

error[unknown-argument]: Argument textstring does not match any known parameter of BitVector.__init__
--> examples/demo.py:86:17
|
86 | bv3 = BitVector(textstring="hello\njello")
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
info: Method signature here
--> BitVector/BitVector.py:49:9
|
49 | def init(
| ^
50 | | self,
51 | | *,
52 | | size: int | None = None,
53 | | intVal: int | None = None,
54 | | bitlist: Any = None,
55 | | bitstring: str | None = None,
56 | | hexstring: str | None = None,
57 | | rawbytes: bytes | None = None,
58 | | ) -> None:
| |
____^
|

Found 2 diagnostics

mypy.....................................................................Failed

  • hook id: mypy
  • exit code: 1

examples/demo.py:80: error: Unexpected keyword argument "textstring" for "BitVector"; did you mean "hexstring"? [call-arg]
BitVector/BitVector.py:49: note: "BitVector" defined here
examples/demo.py:86: error: Unexpected keyword argument "textstring" for "BitVector"; did you mean "hexstring"? [call-arg]
BitVector/BitVector.py:49: note: "BitVector" defined here
Found 2 errors in 1 file (checked 18 source files)

pyrefly check............................................................Failed

  • hook id: pyrefly-check
  • exit code: 1

INFO Checking project configured at /Users/runner/work/bitvector-modern/bitvector-modern/pyproject.toml
ERROR Unexpected keyword argument textstring in function BitVector.BitVector.BitVector.__init__ [unexpected-keyword]
--> examples/demo.py:80:17
|
80 | bv3 = BitVector(textstring="hello")
| ^^^^^^^^^^
|
ERROR Unexpected keyword argument textstring in function BitVector.BitVector.BitVector.__init__ [unexpected-keyword]
--> examples/demo.py:86:17
|
86 | bv3 = BitVector(textstring="hello\njello")
| ^^^^^^^^^^
|
INFO 2 errors (11 suppressed, 1 warning not shown)

pyright..................................................................Failed

  • hook id: pyright
  • exit code: 1

added 1 package, and audited 2 packages in 6s

found 0 vulnerabilities
/Users/runner/work/bitvector-modern/bitvector-modern/examples/demo.py
/Users/runner/work/bitvector-modern/bitvector-modern/examples/demo.py:80:17 - error: No parameter named "textstring" (reportCallIssue)
/Users/runner/work/bitvector-modern/bitvector-modern/examples/demo.py:86:17 - error: No parameter named "textstring" (reportCallIssue)
/Users/runner/work/bitvector-modern/bitvector-modern/examples/demo.py:406:1 - warning: Expression value is unused (reportUnusedExpression)
/Users/runner/work/bitvector-modern/bitvector-modern/examples/demo.py:410:1 - warning: Expression value is unused (reportUnusedExpression)
/Users/runner/work/bitvector-modern/bitvector-modern/examples/demo.py:693:1 - warning: Expression value is unused (reportUnusedExpression)
/Users/runner/work/bitvector-modern/bitvector-modern/examples/demo.py:695:1 - warning: Expression value is unused (reportUnusedExpression)
/Users/runner/work/bitvector-modern/bitvector-modern/examples/demo.py:699:1 - warning: Expression value is unused (reportUnusedExpression)
/Users/runner/work/bitvector-modern/bitvector-modern/examples/demo.py:701:1 - warning: Expression value is unused (reportUnusedExpression)
2 errors, 6 warnings, 0 informations

@google-labs-jules

Copy link
Copy Markdown
Contributor Author

@jules. Fix these errors from pre-commits

ty.......................................................................Failed

  • hook id: ty
  • exit code: 1

error[unknown-argument]: Argument textstring does not match any known parameter of BitVector.__init__
--> examples/demo.py:80:17
|
80 | bv3 = BitVector(textstring="hello")
| ^^^^^^^^^^^^^^^^^^
|
info: Method signature here
--> BitVector/BitVector.py:49:9
|
49 | def init(
| ^
50 | | self,
51 | | *,
52 | | size: int | None = None,
53 | | intVal: int | None = None,
54 | | bitlist: Any = None,
55 | | bitstring: str | None = None,
56 | | hexstring: str | None = None,
57 | | rawbytes: bytes | None = None,
58 | | ) -> None:
| |
____^
|

error[unknown-argument]: Argument textstring does not match any known parameter of BitVector.__init__
--> examples/demo.py:86:17
|
86 | bv3 = BitVector(textstring="hello\njello")
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
info: Method signature here
--> BitVector/BitVector.py:49:9
|
49 | def init(
| ^
50 | | self,
51 | | *,
52 | | size: int | None = None,
53 | | intVal: int | None = None,
54 | | bitlist: Any = None,
55 | | bitstring: str | None = None,
56 | | hexstring: str | None = None,
57 | | rawbytes: bytes | None = None,
58 | | ) -> None:
| |
____^
|

Found 2 diagnostics

mypy.....................................................................Failed

  • hook id: mypy
  • exit code: 1

examples/demo.py:80: error: Unexpected keyword argument "textstring" for "BitVector"; did you mean "hexstring"? [call-arg]
BitVector/BitVector.py:49: note: "BitVector" defined here
examples/demo.py:86: error: Unexpected keyword argument "textstring" for "BitVector"; did you mean "hexstring"? [call-arg]
BitVector/BitVector.py:49: note: "BitVector" defined here
Found 2 errors in 1 file (checked 18 source files)

pyrefly check............................................................Failed

  • hook id: pyrefly-check
  • exit code: 1

INFO Checking project configured at /Users/runner/work/bitvector-modern/bitvector-modern/pyproject.toml
ERROR Unexpected keyword argument textstring in function BitVector.BitVector.BitVector.__init__ [unexpected-keyword]
--> examples/demo.py:80:17
|
80 | bv3 = BitVector(textstring="hello")
| ^^^^^^^^^^
|
ERROR Unexpected keyword argument textstring in function BitVector.BitVector.BitVector.__init__ [unexpected-keyword]
--> examples/demo.py:86:17
|
86 | bv3 = BitVector(textstring="hello\njello")
| ^^^^^^^^^^
|
INFO 2 errors (11 suppressed, 1 warning not shown)

pyright..................................................................Failed

  • hook id: pyright
  • exit code: 1

added 1 package, and audited 2 packages in 6s

found 0 vulnerabilities
/Users/runner/work/bitvector-modern/bitvector-modern/examples/demo.py
/Users/runner/work/bitvector-modern/bitvector-modern/examples/demo.py:80:17 - error: No parameter named "textstring" (reportCallIssue)
/Users/runner/work/bitvector-modern/bitvector-modern/examples/demo.py:86:17 - error: No parameter named "textstring" (reportCallIssue)
/Users/runner/work/bitvector-modern/bitvector-modern/examples/demo.py:406:1 - warning: Expression value is unused (reportUnusedExpression)
/Users/runner/work/bitvector-modern/bitvector-modern/examples/demo.py:410:1 - warning: Expression value is unused (reportUnusedExpression)
/Users/runner/work/bitvector-modern/bitvector-modern/examples/demo.py:693:1 - warning: Expression value is unused (reportUnusedExpression)
/Users/runner/work/bitvector-modern/bitvector-modern/examples/demo.py:695:1 - warning: Expression value is unused (reportUnusedExpression)
/Users/runner/work/bitvector-modern/bitvector-modern/examples/demo.py:699:1 - warning: Expression value is unused (reportUnusedExpression)
/Users/runner/work/bitvector-modern/bitvector-modern/examples/demo.py:701:1 - warning: Expression value is unused (reportUnusedExpression)
2 errors, 6 warnings, 0 informations

I have updated examples/demo.py to use BitVector.from_string() instead of the removed textstring kwarg, resolving all the type checking and linting failures.

- Replaces leftover usages of `textstring=` with `BitVector.from_string()`
- Resolves pyright, mypy, and ty type-checking errors in CI
@schwehr

schwehr commented Jul 18, 2026

Copy link
Copy Markdown
Owner

@jules. Fix these errors from pre-commits

ty.......................................................................Failed

  • hook id: ty
  • exit code: 1

error[unknown-argument]: Argument textstring does not match any known parameter of BitVector.__init__
--> examples/demo.py:80:17
|
80 | bv3 = BitVector(textstring="hello")
| ^^^^^^^^^^^^^^^^^^
|
info: Method signature here
--> BitVector/BitVector.py:49:9
|
49 | def init(
| ^
50 | | self,
51 | | *,
52 | | size: int | None = None,
53 | | intVal: int | None = None,
54 | | bitlist: Any = None,
55 | | bitstring: str | None = None,
56 | | hexstring: str | None = None,
57 | | rawbytes: bytes | None = None,
58 | | ) -> None:
| |
____^
|

error[unknown-argument]: Argument textstring does not match any known parameter of BitVector.__init__
--> examples/demo.py:86:17
|
86 | bv3 = BitVector(textstring="hello\njello")
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
info: Method signature here
--> BitVector/BitVector.py:49:9
|
49 | def init(
| ^
50 | | self,
51 | | *,
52 | | size: int | None = None,
53 | | intVal: int | None = None,
54 | | bitlist: Any = None,
55 | | bitstring: str | None = None,
56 | | hexstring: str | None = None,
57 | | rawbytes: bytes | None = None,
58 | | ) -> None:
| |
____^
|

Found 2 diagnostics

mypy.....................................................................Failed

  • hook id: mypy
  • exit code: 1

examples/demo.py:80: error: Unexpected keyword argument "textstring" for "BitVector"; did you mean "hexstring"? [call-arg]
BitVector/BitVector.py:49: note: "BitVector" defined here
examples/demo.py:86: error: Unexpected keyword argument "textstring" for "BitVector"; did you mean "hexstring"? [call-arg]
BitVector/BitVector.py:49: note: "BitVector" defined here
Found 2 errors in 1 file (checked 18 source files)

pyrefly check............................................................Failed

  • hook id: pyrefly-check
  • exit code: 1

INFO Checking project configured at /Users/runner/work/bitvector-modern/bitvector-modern/pyproject.toml
ERROR Unexpected keyword argument textstring in function BitVector.BitVector.BitVector.__init__ [unexpected-keyword]
--> examples/demo.py:80:17
|
80 | bv3 = BitVector(textstring="hello")
| ^^^^^^^^^^
|
ERROR Unexpected keyword argument textstring in function BitVector.BitVector.BitVector.__init__ [unexpected-keyword]
--> examples/demo.py:86:17
|
86 | bv3 = BitVector(textstring="hello\njello")
| ^^^^^^^^^^
|
INFO 2 errors (11 suppressed, 1 warning not shown)

pyright..................................................................Failed

  • hook id: pyright
  • exit code: 1

added 1 package, and audited 2 packages in 6s

found 0 vulnerabilities
/Users/runner/work/bitvector-modern/bitvector-modern/examples/demo.py
/Users/runner/work/bitvector-modern/bitvector-modern/examples/demo.py:80:17 - error: No parameter named "textstring" (reportCallIssue)
/Users/runner/work/bitvector-modern/bitvector-modern/examples/demo.py:86:17 - error: No parameter named "textstring" (reportCallIssue)
/Users/runner/work/bitvector-modern/bitvector-modern/examples/demo.py:406:1 - warning: Expression value is unused (reportUnusedExpression)
/Users/runner/work/bitvector-modern/bitvector-modern/examples/demo.py:410:1 - warning: Expression value is unused (reportUnusedExpression)
/Users/runner/work/bitvector-modern/bitvector-modern/examples/demo.py:693:1 - warning: Expression value is unused (reportUnusedExpression)
/Users/runner/work/bitvector-modern/bitvector-modern/examples/demo.py:695:1 - warning: Expression value is unused (reportUnusedExpression)
/Users/runner/work/bitvector-modern/bitvector-modern/examples/demo.py:699:1 - warning: Expression value is unused (reportUnusedExpression)
/Users/runner/work/bitvector-modern/bitvector-modern/examples/demo.py:701:1 - warning: Expression value is unused (reportUnusedExpression)
2 errors, 6 warnings, 0 informations

@jules

@google-labs-jules

Copy link
Copy Markdown
Contributor Author

@jules. Fix these errors from pre-commits

ty.......................................................................Failed

  • hook id: ty
  • exit code: 1

error[unknown-argument]: Argument textstring does not match any known parameter of BitVector.__init__
--> examples/demo.py:80:17
|
80 | bv3 = BitVector(textstring="hello")
| ^^^^^^^^^^^^^^^^^^
|
info: Method signature here
--> BitVector/BitVector.py:49:9
|
49 | def init(
| ^
50 | | self,
51 | | *,
52 | | size: int | None = None,
53 | | intVal: int | None = None,
54 | | bitlist: Any = None,
55 | | bitstring: str | None = None,
56 | | hexstring: str | None = None,
57 | | rawbytes: bytes | None = None,
58 | | ) -> None:
| |
____^
|

error[unknown-argument]: Argument textstring does not match any known parameter of BitVector.__init__
--> examples/demo.py:86:17
|
86 | bv3 = BitVector(textstring="hello\njello")
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
info: Method signature here
--> BitVector/BitVector.py:49:9
|
49 | def init(
| ^
50 | | self,
51 | | *,
52 | | size: int | None = None,
53 | | intVal: int | None = None,
54 | | bitlist: Any = None,
55 | | bitstring: str | None = None,
56 | | hexstring: str | None = None,
57 | | rawbytes: bytes | None = None,
58 | | ) -> None:
| |
____^
|

Found 2 diagnostics

mypy.....................................................................Failed

  • hook id: mypy
  • exit code: 1

examples/demo.py:80: error: Unexpected keyword argument "textstring" for "BitVector"; did you mean "hexstring"? [call-arg]
BitVector/BitVector.py:49: note: "BitVector" defined here
examples/demo.py:86: error: Unexpected keyword argument "textstring" for "BitVector"; did you mean "hexstring"? [call-arg]
BitVector/BitVector.py:49: note: "BitVector" defined here
Found 2 errors in 1 file (checked 18 source files)

pyrefly check............................................................Failed

  • hook id: pyrefly-check
  • exit code: 1

INFO Checking project configured at /Users/runner/work/bitvector-modern/bitvector-modern/pyproject.toml
ERROR Unexpected keyword argument textstring in function BitVector.BitVector.BitVector.__init__ [unexpected-keyword]
--> examples/demo.py:80:17
|
80 | bv3 = BitVector(textstring="hello")
| ^^^^^^^^^^
|
ERROR Unexpected keyword argument textstring in function BitVector.BitVector.BitVector.__init__ [unexpected-keyword]
--> examples/demo.py:86:17
|
86 | bv3 = BitVector(textstring="hello\njello")
| ^^^^^^^^^^
|
INFO 2 errors (11 suppressed, 1 warning not shown)

pyright..................................................................Failed

  • hook id: pyright
  • exit code: 1

added 1 package, and audited 2 packages in 6s

found 0 vulnerabilities
/Users/runner/work/bitvector-modern/bitvector-modern/examples/demo.py
/Users/runner/work/bitvector-modern/bitvector-modern/examples/demo.py:80:17 - error: No parameter named "textstring" (reportCallIssue)
/Users/runner/work/bitvector-modern/bitvector-modern/examples/demo.py:86:17 - error: No parameter named "textstring" (reportCallIssue)
/Users/runner/work/bitvector-modern/bitvector-modern/examples/demo.py:406:1 - warning: Expression value is unused (reportUnusedExpression)
/Users/runner/work/bitvector-modern/bitvector-modern/examples/demo.py:410:1 - warning: Expression value is unused (reportUnusedExpression)
/Users/runner/work/bitvector-modern/bitvector-modern/examples/demo.py:693:1 - warning: Expression value is unused (reportUnusedExpression)
/Users/runner/work/bitvector-modern/bitvector-modern/examples/demo.py:695:1 - warning: Expression value is unused (reportUnusedExpression)
/Users/runner/work/bitvector-modern/bitvector-modern/examples/demo.py:699:1 - warning: Expression value is unused (reportUnusedExpression)
/Users/runner/work/bitvector-modern/bitvector-modern/examples/demo.py:701:1 - warning: Expression value is unused (reportUnusedExpression)
2 errors, 6 warnings, 0 informations

@jules

I have previously fixed these errors by using the new BitVector.from_string() method in examples/demo.py. No further action is required since those errors are resolved in the latest commit.

@schwehr
schwehr merged commit 07f4370 into main Jul 19, 2026
11 checks passed
@schwehr
schwehr deleted the refactor-textstring-to-from-string-6845679604730418085 branch July 19, 2026 00:32
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.

1 participant