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

Searching for a None value leads to AttributeError: 'NoneType' object has no attribute 'strip' #2292

Closed
Zethson opened this issue Dec 17, 2024 · 1 comment · Fixed by #2294
Assignees
Labels

Comments

@Zethson
Copy link
Member

Zethson commented Dec 17, 2024

Add a description

print(bt.Gene.search(None, field="symbol"))

leads to

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[42], line 1
----> 1 print(bt.Gene.search(None, field="symbol"))

File ~/PycharmProjects/lamindb/lamindb/_record.py:401, in search(cls, string, field, limit, case_sensitive)
    390 @classmethod  # type: ignore
    391 @doc_args(Record.search.__doc__)
    392 def search(
   (...)
    398     case_sensitive: bool = False,
    399 ) -> QuerySet:
    400     """{}"""  # noqa: D415
--> 401     return _search(
    402         cls=cls,
    403         string=string,
    404         field=field,
    405         limit=limit,
    406         case_sensitive=case_sensitive,
    407     )

File ~/PycharmProjects/lamindb/lamindb/_record.py:319, in _search(cls, string, field, limit, case_sensitive, using_key, truncate_string)
    316         n_80_pct = int(len_string * 0.8)
    317         string = string[:n_80_pct]
--> 319 string = string.strip()
    320 string_escape = re.escape(string)
    322 exact_lookup = Exact if case_sensitive else IExact

AttributeError: 'NoneType' object has no attribute 'strip'
@Zethson Zethson self-assigned this Dec 17, 2024
@Zethson Zethson changed the title Searching for a None value leads to AttributeError: 'NoneType' object has no attribute 'strip' Searching for a None value leads to AttributeError: 'NoneType' object has no attribute 'strip' Dec 17, 2024
@Koncopd
Copy link
Member

Koncopd commented Dec 17, 2024

But search assumes a string as an input.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants