obsidiantools icon indicating copy to clipboard operation
obsidiantools copied to clipboard

TypeError: unsupported operand type(s) for /: 'str' and 'str'

Open hursh-desai opened this issue 3 years ago • 4 comments

Dunno what in my notes could possibly be triggering this error. But it happens whenever I try and use the get_note_metadata() method on my vault. image

hursh-desai avatar Jan 20 '23 11:01 hursh-desai

Seeing the same issue when running vault.get_note_metadata with the vault object.

Output exceeds the size limit. Open the full output data in a text editor
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-16-5147b4bd015c> in <module>
      1 vault.connect()
----> 2 print(vault.get_note_metadata())

~/opt/miniconda3/envs/jupyter/lib/python3.9/site-packages/obsidiantools/api.py in get_note_metadata(self)
   1154               .rename(columns={'file_exists': 'note_exists'})
   1155               .rename_axis('note'))
-> 1156         df = (df.pipe(self._create_note_metadata_columns)
   1157               .pipe(self._clean_up_note_metadata_dtypes)
   1158               )

~/opt/miniconda3/envs/jupyter/lib/python3.9/site-packages/pandas/core/generic.py in pipe(self, func, *args, **kwargs)
   5510         ...  )  # doctest: +SKIP
   5511         """
-> 5512         return com.pipe(self, func, *args, **kwargs)
   5513 
   5514     # ----------------------------------------------------------------------

~/opt/miniconda3/envs/jupyter/lib/python3.9/site-packages/pandas/core/common.py in pipe(obj, func, *args, **kwargs)
    495         return func(*args, **kwargs)
    496     else:
--> 497         return func(obj, *args, **kwargs)
    498 
...
-> 1167                                       [self._dirpath / str(f)
   1168                                        for f in df['rel_filepath'].tolist()],
   1169                                       np.NaN)

TypeError: unsupported operand type(s) for /: 'str' and 'str'

I love the idea of getting a data frame back so thank you for thinking about that.

macdrifter avatar Feb 02 '23 12:02 macdrifter

I ran into this as well—it seems you can get around this by wrapping your supplied vault path in pathlib.Path so that it isn't a raw string.

daneah avatar Apr 09 '23 00:04 daneah

@hursh-desai @macdrifter was this issue from the vault's dirpath not being a pathlib.Path object? (like with @daneah comment) If that's the case, this wouldn't be a bug as the library is set up to use pathlib paths rather than strings for directory arguments (dirpath (pathlib Path) in the docstring).

Pandas pipe functions are neat but maybe not as straightforward for debugging, so I might explore moving some logic away from those.

mfarragher avatar Jun 17 '23 20:06 mfarragher

@mfarragher @hursh-desai I had the same issue as above and changed the vault path to a pathlib.Path object and it worked great. Indeed not a bug but not very explicit in the current documentation.

jb-lafon avatar Oct 17 '24 05:10 jb-lafon

Use the dev branch for code that addresses this. I raise an exception for dirpath values that aren't pathlib.Path type since this commit: https://github.com/mfarragher/obsidiantools/pull/37#issuecomment-3006445012

mfarragher avatar Jun 26 '25 17:06 mfarragher