bitmapist 3.116__tar.gz → 3.117__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,6 @@
1
+ .*.swp
2
+ *.pyc
3
+ *.egg-info
4
+ /dist
5
+ .tox
6
+ dump.rdb
@@ -0,0 +1,26 @@
1
+ Copyright 2012 Doist Ltd.
2
+
3
+ Redistribution and use in source and binary forms, with or without modification,
4
+ are permitted provided that the following conditions are met:
5
+
6
+ 1. Redistributions of source code must retain the above copyright notice, this
7
+ list of conditions and the following disclaimer.
8
+
9
+ 2. Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation and/or
11
+ other materials provided with the distribution.
12
+
13
+ 3. Neither the name of the copyright holder nor the names of its contributors
14
+ may be used to endorse or promote products derived from this software without
15
+ specific prior written permission.
16
+
17
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND
18
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
21
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
24
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -1,29 +1,28 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: bitmapist
3
- Version: 3.116
3
+ Version: 3.117
4
4
  Summary: Implements a powerful analytics library using Redis bitmaps.
5
- License: BSD
6
- Keywords: redis,bitmap,analytics,bitmaps,realtime,cohort
7
- Author: Amir Salihefendic
8
- Author-email: dev@doist.com
9
- Requires-Python: >=3.9,<3.13
5
+ Project-URL: Repository, https://github.com/Doist/bitmapist
6
+ Author-email: Amir Salihefendic <dev@doist.com>, Doist Developers <dev@doist.com>
7
+ License-Expression: BSD-3-Clause
8
+ License-File: AUTHORS
9
+ License-File: LICENSE
10
+ Keywords: analytics,bitmap,bitmaps,cohort,realtime,redis
10
11
  Classifier: Development Status :: 5 - Production/Stable
11
12
  Classifier: Intended Audience :: Developers
12
- Classifier: License :: OSI Approved :: BSD License
13
- Classifier: License :: Other/Proprietary License
14
13
  Classifier: Operating System :: OS Independent
15
14
  Classifier: Programming Language :: Python
16
- Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3 :: Only
17
16
  Classifier: Programming Language :: Python :: 3.9
18
17
  Classifier: Programming Language :: Python :: 3.10
19
18
  Classifier: Programming Language :: Python :: 3.11
20
19
  Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
21
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
- Requires-Dist: Mako (>=1.0.4,<2.0.0)
23
- Requires-Dist: future (>=0.14.3,<0.19.0)
22
+ Requires-Python: <3.14,>=3.9
23
+ Requires-Dist: mako<2,>=1.0.4
24
24
  Requires-Dist: python-dateutil
25
- Requires-Dist: redis (>=2.10,<6.0)
26
- Project-URL: Repository, https://github.com/Doist/bitmapist
25
+ Requires-Dist: redis<6.0,>=2.10
27
26
  Description-Content-Type: text/markdown
28
27
 
29
28
  ![bitmapist](https://raw.githubusercontent.com/Doist/bitmapist/master/static/bitmapist.png "bitmapist")
@@ -71,6 +70,10 @@ Can be installed very easily via:
71
70
 
72
71
  $ pip install bitmapist
73
72
 
73
+ Or, if you use `uv`:
74
+
75
+ $ uv add bitmapist
76
+
74
77
 
75
78
  # Ports
76
79
 
@@ -359,36 +362,49 @@ Please see our guide [here](./CONTRIBUTING.md)
359
362
 
360
363
  ## Local Development
361
364
 
362
- We use Poetry for dependency management & packaging. Please see [here for setup instructions](https://python-poetry.org/docs/#installation).
365
+ We use `uv` for dependency management & packaging. Please see [here for setup instructions](https://docs.astral.sh/uv/getting-started/).
363
366
 
364
- Once you have Poetry installed, you can run the following to install the dependencies in a virtual environment:
367
+ Once you have `uv` installed, you can run the following to install the dependencies in a virtual environment:
365
368
 
366
369
  ```bash
367
- poetry install
370
+ uv sync
368
371
  ```
369
372
 
370
373
  ## Testing
371
374
 
372
375
  To run our tests will need to ensure a local redis server is installed.
373
376
 
374
- We use pytest to run unittests which you can run in a poetry shell with
377
+ You can use these environment variables to tell the tests about Redis:
378
+
379
+ * `BITMAPIST_REDIS_SERVER_PATH`: Path to the Redis server executable (defaults to the first one in the path or `/usr/bin/redis-server`)
380
+ * `BITMAPIST_REDIS_PORT`: Port number for the Redis server (defaults to 6399)
381
+
382
+ We use `pytest` to run unit tests, which you can run with:
375
383
 
376
384
  ```bash
377
- poetry run pytest
385
+ uv run pytest
378
386
  ```
379
387
 
380
388
  ## Releasing new versions
381
389
 
382
- - Bump version in `pyproject.toml`
383
- - Update the CHANGELOG
384
- - Commit the changes with a commit message "Version X.X.X"
385
- - Tag the current commit with `vX.X.X`
386
- - Create a new release on GitHub named `vX.X.X`
387
- - GitHub Actions will publish the new version to PIP for you
390
+ 1. Bump version in `pyproject.toml` (or use `uv version`)
391
+ ```sh
392
+ uv version --bump minor
393
+ ```
394
+ 1. Update the CHANGELOG
395
+ 1. Commit the changes with a commit message "Version X.X.X"
396
+ ```sh
397
+ git commit -m "Version $(uv version --short)"
398
+ ```
399
+ 1. Tag the current commit with `vX.X.X`
400
+ ```sh
401
+ git tag -a -m "Release $(uv version --short)" "v$(uv version --short)"
402
+ ```
403
+ 1. Create a new release on GitHub named `vX.X.X`
404
+ 1. GitHub Actions will publish the new version to PyPI for you
388
405
 
389
406
  ## Legal
390
407
 
391
408
  Copyright: 2012 by Doist Ltd.
392
409
 
393
- License: BSD
394
-
410
+ License: BSD-3-Clause
@@ -43,6 +43,10 @@ Can be installed very easily via:
43
43
 
44
44
  $ pip install bitmapist
45
45
 
46
+ Or, if you use `uv`:
47
+
48
+ $ uv add bitmapist
49
+
46
50
 
47
51
  # Ports
48
52
 
@@ -331,35 +335,49 @@ Please see our guide [here](./CONTRIBUTING.md)
331
335
 
332
336
  ## Local Development
333
337
 
334
- We use Poetry for dependency management & packaging. Please see [here for setup instructions](https://python-poetry.org/docs/#installation).
338
+ We use `uv` for dependency management & packaging. Please see [here for setup instructions](https://docs.astral.sh/uv/getting-started/).
335
339
 
336
- Once you have Poetry installed, you can run the following to install the dependencies in a virtual environment:
340
+ Once you have `uv` installed, you can run the following to install the dependencies in a virtual environment:
337
341
 
338
342
  ```bash
339
- poetry install
343
+ uv sync
340
344
  ```
341
345
 
342
346
  ## Testing
343
347
 
344
348
  To run our tests will need to ensure a local redis server is installed.
345
349
 
346
- We use pytest to run unittests which you can run in a poetry shell with
350
+ You can use these environment variables to tell the tests about Redis:
351
+
352
+ * `BITMAPIST_REDIS_SERVER_PATH`: Path to the Redis server executable (defaults to the first one in the path or `/usr/bin/redis-server`)
353
+ * `BITMAPIST_REDIS_PORT`: Port number for the Redis server (defaults to 6399)
354
+
355
+ We use `pytest` to run unit tests, which you can run with:
347
356
 
348
357
  ```bash
349
- poetry run pytest
358
+ uv run pytest
350
359
  ```
351
360
 
352
361
  ## Releasing new versions
353
362
 
354
- - Bump version in `pyproject.toml`
355
- - Update the CHANGELOG
356
- - Commit the changes with a commit message "Version X.X.X"
357
- - Tag the current commit with `vX.X.X`
358
- - Create a new release on GitHub named `vX.X.X`
359
- - GitHub Actions will publish the new version to PIP for you
363
+ 1. Bump version in `pyproject.toml` (or use `uv version`)
364
+ ```sh
365
+ uv version --bump minor
366
+ ```
367
+ 1. Update the CHANGELOG
368
+ 1. Commit the changes with a commit message "Version X.X.X"
369
+ ```sh
370
+ git commit -m "Version $(uv version --short)"
371
+ ```
372
+ 1. Tag the current commit with `vX.X.X`
373
+ ```sh
374
+ git tag -a -m "Release $(uv version --short)" "v$(uv version --short)"
375
+ ```
376
+ 1. Create a new release on GitHub named `vX.X.X`
377
+ 1. GitHub Actions will publish the new version to PyPI for you
360
378
 
361
379
  ## Legal
362
380
 
363
381
  Copyright: 2012 by Doist Ltd.
364
382
 
365
- License: BSD
383
+ License: BSD-3-Clause
@@ -76,11 +76,12 @@ Additionally you can supply an extra argument to mark_event to bypass the defaul
76
76
 
77
77
  :copyright: 2012 by Doist Ltd.
78
78
  :developer: Amir Salihefendic ( http://amix.dk )
79
- :license: BSD
79
+ :license: BSD-3-Clause
80
80
  """
81
81
 
82
82
  from __future__ import annotations
83
83
 
84
+ import abc
84
85
  import calendar
85
86
  import threading
86
87
  from collections import defaultdict
@@ -292,7 +293,7 @@ def get_event_names(
292
293
  `prefix` value is used to filter only subset of keys
293
294
  """
294
295
  cli = get_redis(system)
295
- expr = "trackist_%s*" % prefix
296
+ expr = f"trackist_{prefix}*"
296
297
  ret = set()
297
298
  for result in cli.scan_iter(match=expr, count=batch):
298
299
  result = result.decode()
@@ -400,6 +401,9 @@ class MixinEventsMisc:
400
401
  return NotImplemented
401
402
  return self.redis_key == other_key
402
403
 
404
+ def __hash__(self):
405
+ return hash(self.redis_key)
406
+
403
407
 
404
408
  class MixinCounts:
405
409
  """
@@ -427,9 +431,7 @@ class MixinContains:
427
431
 
428
432
  def __contains__(self, uuid):
429
433
  cli = get_redis(self.system)
430
- if cli.getbit(self.redis_key, uuid):
431
- return True
432
- return False
434
+ return bool(cli.getbit(self.redis_key, uuid))
433
435
 
434
436
 
435
437
  class UniqueEvents(
@@ -452,8 +454,34 @@ class UniqueEvents(
452
454
 
453
455
 
454
456
  class GenericPeriodEvents(
455
- MixinIter, MixinCounts, MixinContains, MixinEventsMisc, MixinBitOperations
457
+ MixinIter, MixinCounts, MixinContains, MixinEventsMisc, MixinBitOperations, abc.ABC
456
458
  ):
459
+ """
460
+ This is an abstract base class - subclasses must call super().__init__()
461
+ and implement their specific initialization logic. They all must set the
462
+ redis_key attribute in __init__.
463
+ """
464
+
465
+ def __init__(self, event_name: str, *, system: str = "default"):
466
+ self.event_name = event_name
467
+ self.system = system
468
+ # redis_key will be set by subclasses
469
+
470
+ @abc.abstractmethod
471
+ def delta(self, value: int):
472
+ """Return a new instance with the period offset by value."""
473
+ ...
474
+
475
+ @abc.abstractmethod
476
+ def period_start(self) -> datetime:
477
+ """Return the start datetime of this period."""
478
+ ...
479
+
480
+ @abc.abstractmethod
481
+ def period_end(self) -> datetime:
482
+ """Return the end datetime of this period."""
483
+ ...
484
+
457
485
  def next(self):
458
486
  """Next object in a datetime line"""
459
487
  return self.delta(value=1)
@@ -516,11 +544,10 @@ class MonthEvents(GenericPeriodEvents):
516
544
  return cls(event_name, dt.year, dt.month, system=system)
517
545
 
518
546
  def __init__(self, event_name, year=None, month=None, system="default"):
547
+ super().__init__(event_name, system=system)
519
548
  now = datetime.now(tz=timezone.utc)
520
- self.event_name = event_name
521
549
  self.year = not_none(year, now.year)
522
550
  self.month = not_none(month, now.month)
523
- self.system = system
524
551
  self.redis_key = _prefix_key(event_name, f"{self.year}-{self.month}")
525
552
 
526
553
  def delta(self, value):
@@ -558,12 +585,11 @@ class WeekEvents(GenericPeriodEvents):
558
585
  return cls(event_name, dt_year, dt_week, system=system)
559
586
 
560
587
  def __init__(self, event_name: str, year=None, week=None, system="default"):
588
+ super().__init__(event_name, system=system)
561
589
  now = datetime.now(tz=timezone.utc)
562
590
  now_year, now_week, _ = now.isocalendar()
563
- self.event_name = event_name
564
591
  self.year = not_none(year, now_year)
565
592
  self.week = not_none(week, now_week)
566
- self.system = system
567
593
  self.redis_key = _prefix_key(event_name, f"W{self.year}-{self.week}")
568
594
 
569
595
  def delta(self, value):
@@ -597,12 +623,11 @@ class DayEvents(GenericPeriodEvents):
597
623
  return cls(event_name, dt.year, dt.month, dt.day, system=system)
598
624
 
599
625
  def __init__(self, event_name, year=None, month=None, day=None, system="default"):
626
+ super().__init__(event_name, system=system)
600
627
  now = datetime.now(tz=timezone.utc)
601
- self.event_name = event_name
602
628
  self.year = not_none(year, now.year)
603
629
  self.month = not_none(month, now.month)
604
630
  self.day = not_none(day, now.day)
605
- self.system = system
606
631
  self.redis_key = _prefix_key(event_name, f"{self.year}-{self.month}-{self.day}")
607
632
 
608
633
  def delta(self, value):
@@ -643,13 +668,12 @@ class HourEvents(GenericPeriodEvents):
643
668
  hour: Optional[int] = None,
644
669
  system: str = "default",
645
670
  ):
671
+ super().__init__(event_name, system=system)
646
672
  now = datetime.now(tz=timezone.utc)
647
- self.event_name = event_name
648
673
  self.year = not_none(year, now.year)
649
674
  self.month = not_none(month, now.month)
650
675
  self.day = not_none(day, now.day)
651
676
  self.hour = not_none(hour, now.hour)
652
- self.system = system
653
677
  self.redis_key = _prefix_key(
654
678
  event_name, f"{self.year}-{self.month}-{self.day}-{self.hour}"
655
679
  )
@@ -59,7 +59,7 @@ Get the data and render it via HTML::
59
59
 
60
60
  :copyright: 2012 by Doist Ltd.
61
61
  :developer: Amir Salihefendic ( http://amix.dk )
62
- :license: BSD
62
+ :license: BSD-3-Clause
63
63
  """
64
64
 
65
65
  from datetime import date, datetime, timedelta, timezone
@@ -415,4 +415,4 @@ def get_lookup() -> TemplateLookup:
415
415
  return _LOOKUP
416
416
 
417
417
 
418
- __all__ = ["render_html_form", "render_html_data", "get_dates_data"]
418
+ __all__ = ["get_dates_data", "render_html_data", "render_html_form"]
@@ -1,55 +1,77 @@
1
- [tool.poetry]
1
+ [project]
2
2
  name = "bitmapist"
3
- version = "3.116"
4
- description="Implements a powerful analytics library using Redis bitmaps."
3
+ version = "3.117"
4
+ description = "Implements a powerful analytics library using Redis bitmaps."
5
5
  authors = [
6
- "Amir Salihefendic <dev@doist.com>",
7
- "Doist Developers <dev@doist.com>",
6
+ { name = "Amir Salihefendic", email = "dev@doist.com" },
7
+ { name = "Doist Developers", email = "dev@doist.com" },
8
8
  ]
9
- license="BSD"
9
+ requires-python = ">=3.9,<3.14"
10
10
  readme = "README.md"
11
- repository = "https://github.com/Doist/bitmapist"
12
- keywords=[ "redis", "bitmap", "analytics", "bitmaps", "realtime", "cohort", ]
13
- classifiers=[
11
+ license = "BSD-3-Clause"
12
+ keywords = [
13
+ "redis",
14
+ "bitmap",
15
+ "analytics",
16
+ "bitmaps",
17
+ "realtime",
18
+ "cohort",
19
+ ]
20
+ classifiers = [
14
21
  "Development Status :: 5 - Production/Stable",
15
22
  "Intended Audience :: Developers",
16
- "License :: OSI Approved :: BSD License",
17
23
  "Operating System :: OS Independent",
18
24
  "Programming Language :: Python",
19
- "Programming Language :: Python :: 3",
25
+ "Programming Language :: Python :: 3 :: Only",
20
26
  "Programming Language :: Python :: 3.9",
21
27
  "Programming Language :: Python :: 3.10",
22
28
  "Programming Language :: Python :: 3.11",
23
29
  "Programming Language :: Python :: 3.12",
30
+ "Programming Language :: Python :: 3.13",
24
31
  "Topic :: Software Development :: Libraries :: Python Modules",
25
32
  ]
26
- packages=[ { include = "bitmapist" } ]
27
- exclude = ['tests/']
33
+ dependencies = [
34
+ "redis>=2.10,<6.0",
35
+ "python-dateutil",
36
+ "Mako>=1.0.4,<2",
37
+ ]
38
+
39
+ [project.urls]
40
+ Repository = "https://github.com/Doist/bitmapist"
41
+
42
+ [dependency-groups]
43
+ dev = [
44
+ "pytest-runner",
45
+ "pytest",
46
+ "pre-commit",
47
+ "tox",
48
+ "mypy",
49
+ "ruff>=0.12.0",
50
+ ]
51
+
52
+ [tool.hatch.build.targets.sdist]
28
53
  include = [
29
- 'AUTHORS',
30
- 'README.md',
31
- 'static/bitmapist.png',
32
- 'static/bitmapist.svg',
54
+ "bitmapist",
55
+ "AUTHORS",
56
+ "README.md",
57
+ "static/bitmapist.png",
58
+ "static/bitmapist.svg",
33
59
  ]
60
+ exclude = ["tests/"]
34
61
 
35
- [tool.poetry.dependencies]
36
- python = ">=3.9,<3.13"
37
- redis = ">=2.10,<6.0"
38
- python-dateutil = "*"
39
- future = ">=0.14.3,<0.19.0"
40
- Mako= "^1.0.4"
41
-
42
- [tool.poetry.dev-dependencies]
43
- pytest-runner = "*"
44
- pytest = "*"
45
- pre-commit = "*"
46
- tox = "*"
47
- mypy = "*"
48
- ruff = "^0.4.1"
62
+ [tool.hatch.build.targets.wheel]
63
+ include = [
64
+ "bitmapist",
65
+ "AUTHORS",
66
+ "README.md",
67
+ "static/bitmapist.png",
68
+ "static/bitmapist.svg",
69
+ ]
70
+ exclude = ["tests/"]
49
71
 
50
72
  [build-system]
51
- requires = ["poetry-core>=1.0.0"]
52
- build-backend = "poetry.core.masonry.api"
73
+ requires = ["hatchling"]
74
+ build-backend = "hatchling.build"
53
75
 
54
76
  [tool.ruff]
55
77
  # By default, always show source code snippets.
@@ -140,11 +162,9 @@ ignore = [
140
162
  "RUF002", # ambiguous-unicode-character-docstring
141
163
  "RUF003", # ambiguous-unicode-character-comment
142
164
  "RUF012", # mutable-class-default
165
+ "RUF200", # invalid-pyproject-toml
143
166
 
144
- # Enable when Poetry supports PEP 621 and we migrate our confguration to it.
145
- # See: https://github.com/python-poetry/poetry-core/pull/567
146
- "RUF200",
147
-
167
+ ## S - flake8-bandit ##
148
168
  "S101", # assert
149
169
  "S104", # hardcoded-bind-all-interfaces
150
170
  "S105", # hardcoded-password-string
@@ -161,9 +181,6 @@ ignore = [
161
181
  "SIM102", # collapsible-if
162
182
  "SIM114", # if-with-same-arms
163
183
  "SIM117", # multiple-with-statements
164
-
165
- # Enable when the rule is out of preview and false-positives are handled.
166
- # See: https://docs.astral.sh/ruff/rules/in-dict-keys/
167
184
  "SIM118", # in-dict-keys
168
185
 
169
186
  ## TRY - tryceratops ##
@@ -178,12 +195,8 @@ ignore = [
178
195
  "RET504", # unnecessary-assign
179
196
 
180
197
  ## PT - flake8-pytest-style ##
181
- "PT004", # pytest-missing-fixture-name-underscore
182
198
  "PT012", # pytest-raises-with-multiple-statements
183
199
 
184
- ## UP - pyupgrade ##
185
- "UP038", # non-pep604-isinstance
186
-
187
200
  ## B - flake8-bugbear ##
188
201
  "B008", # function-call-in-default-argument
189
202
  "B009", # get-attr-with-constant
@@ -233,3 +246,7 @@ keep-runtime-typing = true
233
246
 
234
247
  [tool.ruff.format]
235
248
  docstring-code-format = true
249
+
250
+ [[tool.mypy.overrides]]
251
+ module = ["mako.*"]
252
+ ignore_missing_imports = true
File without changes
File without changes